diff --git a/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md b/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md index ef35dc3eeec4..a0fddfd0ef6b 100644 --- a/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md +++ b/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md @@ -1,5 +1,110 @@ # Release History +## 3.0.0b1 (2026-05-06) + +### Features Added + + - Client `ChaosManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `ChaosManagementClient` added method `send_request` + - Client `ChaosManagementClient` added operation group `private_accesses` + - Client `ChaosManagementClient` added operation group `actions` + - Client `ChaosManagementClient` added operation group `action_versions` + - Client `ChaosManagementClient` added operation group `workspaces` + - Client `ChaosManagementClient` added operation group `discovered_resources` + - Client `ChaosManagementClient` added operation group `scenarios` + - Client `ChaosManagementClient` added operation group `scenario_runs` + - Client `ChaosManagementClient` added operation group `scenario_configurations` + - Model `ExperimentExecutionDetailsProperties` added property `provisioning_state` + - Enum `ProvisioningState` added member `RUNNING` + - Added model `Action` + - Added model `ActionDependency` + - Added enum `ActionDependencyType` + - Added enum `ActionKind` + - Added enum `ActionLifecycle` + - Added model `ActionProperties` + - Added model `ActionSupportedTargetType` + - Added model `ActionVersion` + - Added model `ConfigurationExclusions` + - Added model `ConfigurationFilters` + - Added model `CustomerDataStorageProperties` + - Added model `DiscoveredResource` + - Added model `DiscoveredResourceProperties` + - Added model `EntraIdentity` + - Added model `ExternalResource` + - Added model `FixResourcePermissionsRequest` + - Added model `OperationError` + - Added enum `ParameterType` + - Added model `PermissionError` + - Added model `PermissionsFix` + - Added model `PermissionsFixProperties` + - Added enum `PermissionsFixState` + - Added model `PermissionsFixSummary` + - Added model `PhysicalToLogicalZoneMapping` + - Added model `PrivateAccess` + - Added model `PrivateAccessPatch` + - Added model `PrivateAccessProperties` + - Added model `PrivateEndpoint` + - Added model `PrivateEndpointConnection` + - Added model `PrivateEndpointConnectionProperties` + - Added enum `PrivateEndpointServiceConnectionStatus` + - Added model `PrivateLinkResource` + - Added model `PrivateLinkResourceListResult` + - Added model `PrivateLinkResourceProperties` + - Added model `PrivateLinkServiceConnectionState` + - Added enum `PublicNetworkAccessOption` + - Added model `Recommendation` + - Added enum `RecommendationStatus` + - Added model `ResourceStateError` + - Added model `RoleAssignmentError` + - Added model `RoleAssignmentResult` + - Added enum `RoleAssignmentStatus` + - Added model `RunAfter` + - Added enum `RunAfterBehavior` + - Added model `Scenario` + - Added model `ScenarioAction` + - Added model `ScenarioConfiguration` + - Added model `ScenarioConfigurationProperties` + - Added model `ScenarioErrors` + - Added model `ScenarioEvaluationResultItem` + - Added model `ScenarioParameter` + - Added model `ScenarioProperties` + - Added model `ScenarioRun` + - Added model `ScenarioRunProperties` + - Added model `ScenarioRunResource` + - Added enum `ScenarioRunState` + - Added model `ScenarioRunSummaryAction` + - Added enum `ScenarioSummaryState` + - Added enum `ScenarioValidationState` + - Added model `Validation` + - Added model `ValidationProperties` + - Added model `Workspace` + - Added model `WorkspaceEvaluation` + - Added model `WorkspaceEvaluationProperties` + - Added enum `WorkspaceEvaluationStatus` + - Added model `WorkspaceProperties` + - Added model `WorkspaceUpdate` + - Added model `ZoneResolutionInfo` + - Added model `ZoneResolutionMapping` + - Added enum `ZoneResolutionMode` + - Added operation group `ActionVersionsOperations` + - Added operation group `ActionsOperations` + - Added operation group `DiscoveredResourcesOperations` + - Added operation group `PrivateAccessesOperations` + - Added operation group `ScenarioConfigurationsOperations` + - Added operation group `ScenarioRunsOperations` + - Added operation group `ScenariosOperations` + - Added operation group `WorkspacesOperations` + +### Breaking Changes + + - For the method breakings, please refer to https://aka.ms/azsdk/python/migrate/operations for migration. + - Method `CapabilitiesOperations.list` changed its parameter `continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `CapabilityTypesOperations.list` changed its parameter `continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ExperimentsOperations.list` changed its parameter `running`/`continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ExperimentsOperations.list_all` changed its parameter `running`/`continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `TargetTypesOperations.list` changed its parameter `continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `TargetsOperations.list` changed its parameter `continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + ## 2.0.0 (2025-06-12) ### Features Added diff --git a/sdk/chaos/azure-mgmt-chaos/MANIFEST.in b/sdk/chaos/azure-mgmt-chaos/MANIFEST.in index 6eaed6780374..bbe80d989765 100644 --- a/sdk/chaos/azure-mgmt-chaos/MANIFEST.in +++ b/sdk/chaos/azure-mgmt-chaos/MANIFEST.in @@ -1,7 +1,7 @@ -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/chaos/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/chaos/azure-mgmt-chaos/README.md b/sdk/chaos/azure-mgmt-chaos/README.md index 8cc1e3b3057a..696eabbfe567 100644 --- a/sdk/chaos/azure-mgmt-chaos/README.md +++ b/sdk/chaos/azure-mgmt-chaos/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Chaos 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 diff --git a/sdk/chaos/azure-mgmt-chaos/_metadata.json b/sdk/chaos/azure-mgmt-chaos/_metadata.json index a8c1801a8b32..fb14511ae5ee 100644 --- a/sdk/chaos/azure-mgmt-chaos/_metadata.json +++ b/sdk/chaos/azure-mgmt-chaos/_metadata.json @@ -1,11 +1,10 @@ { - "commit": "82e9c6f9fbfa2d6d47d5e2a6a11c0ad2eb345c43", + "apiVersion": "2026-05-01-preview", + "apiVersions": { + "Microsoft.Chaos": "2026-05-01-preview" + }, + "commit": "84d40416fbb3d2416cb7abe7ec82e63c76832963", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.35.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/chaos/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.35.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/chaos/resource-manager/readme.md" + "typespec_src": "specification/chaos/resource-manager/Microsoft.Chaos/Chaos", + "emitterVersion": "0.61.3" } \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/apiview-properties.json b/sdk/chaos/azure-mgmt-chaos/apiview-properties.json new file mode 100644 index 000000000000..87ef1f6937ed --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/apiview-properties.json @@ -0,0 +1,255 @@ +{ + "CrossLanguagePackageId": "Microsoft.Chaos", + "CrossLanguageDefinitionId": { + "azure.mgmt.chaos.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.chaos.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.chaos.models.Action": "Microsoft.Chaos.Action", + "azure.mgmt.chaos.models.ActionDependency": "Microsoft.Chaos.ActionDependency", + "azure.mgmt.chaos.models.ActionProperties": "Microsoft.Chaos.ActionProperties", + "azure.mgmt.chaos.models.ActionStatus": "Microsoft.Chaos.ActionStatus", + "azure.mgmt.chaos.models.ActionSupportedTargetType": "Microsoft.Chaos.ActionSupportedTargetType", + "azure.mgmt.chaos.models.ActionVersion": "Microsoft.Chaos.ActionVersion", + "azure.mgmt.chaos.models.BranchStatus": "Microsoft.Chaos.BranchStatus", + "azure.mgmt.chaos.models.Capability": "Microsoft.Chaos.Capability", + "azure.mgmt.chaos.models.CapabilityProperties": "Microsoft.Chaos.CapabilityProperties", + "azure.mgmt.chaos.models.CapabilityType": "Microsoft.Chaos.CapabilityType", + "azure.mgmt.chaos.models.CapabilityTypeProperties": "Microsoft.Chaos.CapabilityTypeProperties", + "azure.mgmt.chaos.models.CapabilityTypePropertiesRuntimeProperties": "Microsoft.Chaos.CapabilityTypePropertiesRuntimeProperties", + "azure.mgmt.chaos.models.ChaosExperimentAction": "Microsoft.Chaos.ChaosExperimentAction", + "azure.mgmt.chaos.models.ChaosExperimentBranch": "Microsoft.Chaos.ChaosExperimentBranch", + "azure.mgmt.chaos.models.ChaosExperimentStep": "Microsoft.Chaos.ChaosExperimentStep", + "azure.mgmt.chaos.models.ChaosTargetFilter": "Microsoft.Chaos.ChaosTargetFilter", + "azure.mgmt.chaos.models.ChaosTargetSelector": "Microsoft.Chaos.ChaosTargetSelector", + "azure.mgmt.chaos.models.ChaosTargetListSelector": "Microsoft.Chaos.ChaosTargetListSelector", + "azure.mgmt.chaos.models.ChaosTargetQuerySelector": "Microsoft.Chaos.ChaosTargetQuerySelector", + "azure.mgmt.chaos.models.ChaosTargetSimpleFilter": "Microsoft.Chaos.ChaosTargetSimpleFilter", + "azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters": "Microsoft.Chaos.ChaosTargetSimpleFilterParameters", + "azure.mgmt.chaos.models.ConfigurationExclusions": "Microsoft.Chaos.ConfigurationExclusions", + "azure.mgmt.chaos.models.ConfigurationFilters": "Microsoft.Chaos.ConfigurationFilters", + "azure.mgmt.chaos.models.ContinuousAction": "Microsoft.Chaos.ContinuousAction", + "azure.mgmt.chaos.models.CustomerDataStorageProperties": "Microsoft.Chaos.CustomerDataStorageProperties", + "azure.mgmt.chaos.models.DelayAction": "Microsoft.Chaos.DelayAction", + "azure.mgmt.chaos.models.DiscoveredResource": "Microsoft.Chaos.DiscoveredResource", + "azure.mgmt.chaos.models.DiscoveredResourceProperties": "Microsoft.Chaos.DiscoveredResourceProperties", + "azure.mgmt.chaos.models.DiscreteAction": "Microsoft.Chaos.DiscreteAction", + "azure.mgmt.chaos.models.EntraIdentity": "Microsoft.Chaos.EntraIdentity", + "azure.mgmt.chaos.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.chaos.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.chaos.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.chaos.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.chaos.models.Experiment": "Microsoft.Chaos.Experiment", + "azure.mgmt.chaos.models.ExperimentExecution": "Microsoft.Chaos.ExperimentExecution", + "azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsError": "Microsoft.Chaos.ExperimentExecutionActionTargetDetailsError", + "azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsProperties": "Microsoft.Chaos.ExperimentExecutionActionTargetDetailsProperties", + "azure.mgmt.chaos.models.ExperimentExecutionDetails": "Microsoft.Chaos.ExperimentExecutionDetails", + "azure.mgmt.chaos.models.ExperimentExecutionDetailsProperties": "Microsoft.Chaos.ExperimentExecutionDetailsProperties", + "azure.mgmt.chaos.models.ExperimentExecutionDetailsPropertiesRunInformation": "Microsoft.Chaos.ExperimentExecutionDetailsPropertiesRunInformation", + "azure.mgmt.chaos.models.ExperimentExecutionProperties": "Microsoft.Chaos.ExperimentExecutionProperties", + "azure.mgmt.chaos.models.ExperimentProperties": "Microsoft.Chaos.ExperimentProperties", + "azure.mgmt.chaos.models.ExperimentUpdate": "Microsoft.Chaos.ExperimentUpdate", + "azure.mgmt.chaos.models.ExternalResource": "Microsoft.Chaos.ExternalResource", + "azure.mgmt.chaos.models.FixResourcePermissionsRequest": "Microsoft.Chaos.FixResourcePermissionsRequest", + "azure.mgmt.chaos.models.KeyValuePair": "Microsoft.Chaos.KeyValuePair", + "azure.mgmt.chaos.models.ManagedServiceIdentity": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", + "azure.mgmt.chaos.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.chaos.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.chaos.models.OperationError": "Microsoft.Chaos.OperationError", + "azure.mgmt.chaos.models.OperationStatusResult": "Azure.ResourceManager.CommonTypes.OperationStatusResult", + "azure.mgmt.chaos.models.PermissionError": "Microsoft.Chaos.PermissionError", + "azure.mgmt.chaos.models.PermissionsFix": "Microsoft.Chaos.PermissionsFix", + "azure.mgmt.chaos.models.PermissionsFixProperties": "Microsoft.Chaos.PermissionsFixProperties", + "azure.mgmt.chaos.models.PermissionsFixSummary": "Microsoft.Chaos.PermissionsFixSummary", + "azure.mgmt.chaos.models.PhysicalToLogicalZoneMapping": "Microsoft.Chaos.PhysicalToLogicalZoneMapping", + "azure.mgmt.chaos.models.PrivateAccess": "Microsoft.Chaos.PrivateAccess", + "azure.mgmt.chaos.models.PrivateAccessPatch": "Microsoft.Chaos.PrivateAccessPatch", + "azure.mgmt.chaos.models.PrivateAccessProperties": "Microsoft.Chaos.PrivateAccessProperties", + "azure.mgmt.chaos.models.PrivateEndpoint": "Microsoft.Chaos.PrivateEndpoint", + "azure.mgmt.chaos.models.PrivateEndpointConnection": "Microsoft.Chaos.PrivateEndpointConnection", + "azure.mgmt.chaos.models.PrivateEndpointConnectionProperties": "Microsoft.Chaos.PrivateEndpointConnectionProperties", + "azure.mgmt.chaos.models.PrivateLinkResource": "Microsoft.Chaos.PrivateLinkResource", + "azure.mgmt.chaos.models.PrivateLinkResourceListResult": "Microsoft.Chaos.PrivateLinkResourceListResult", + "azure.mgmt.chaos.models.PrivateLinkResourceProperties": "Microsoft.Chaos.PrivateLinkResourceProperties", + "azure.mgmt.chaos.models.PrivateLinkServiceConnectionState": "Microsoft.Chaos.PrivateLinkServiceConnectionState", + "azure.mgmt.chaos.models.Recommendation": "Microsoft.Chaos.Recommendation", + "azure.mgmt.chaos.models.ResourceStateError": "Microsoft.Chaos.ResourceStateError", + "azure.mgmt.chaos.models.RoleAssignmentError": "Microsoft.Chaos.RoleAssignmentError", + "azure.mgmt.chaos.models.RoleAssignmentResult": "Microsoft.Chaos.RoleAssignmentResult", + "azure.mgmt.chaos.models.RunAfter": "Microsoft.Chaos.RunAfter", + "azure.mgmt.chaos.models.Scenario": "Microsoft.Chaos.Scenario", + "azure.mgmt.chaos.models.ScenarioAction": "Microsoft.Chaos.ScenarioAction", + "azure.mgmt.chaos.models.ScenarioConfiguration": "Microsoft.Chaos.ScenarioConfiguration", + "azure.mgmt.chaos.models.ScenarioConfigurationProperties": "Microsoft.Chaos.ScenarioConfigurationProperties", + "azure.mgmt.chaos.models.ScenarioErrors": "Microsoft.Chaos.ScenarioErrors", + "azure.mgmt.chaos.models.ScenarioEvaluationResultItem": "Microsoft.Chaos.ScenarioEvaluationResultItem", + "azure.mgmt.chaos.models.ScenarioParameter": "Microsoft.Chaos.ScenarioParameter", + "azure.mgmt.chaos.models.ScenarioProperties": "Microsoft.Chaos.ScenarioProperties", + "azure.mgmt.chaos.models.ScenarioRun": "Microsoft.Chaos.ScenarioRun", + "azure.mgmt.chaos.models.ScenarioRunProperties": "Microsoft.Chaos.ScenarioRunProperties", + "azure.mgmt.chaos.models.ScenarioRunResource": "Microsoft.Chaos.ScenarioRunResource", + "azure.mgmt.chaos.models.ScenarioRunSummaryAction": "Microsoft.Chaos.ScenarioRunSummaryAction", + "azure.mgmt.chaos.models.StepStatus": "Microsoft.Chaos.StepStatus", + "azure.mgmt.chaos.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.chaos.models.Target": "Microsoft.Chaos.Target", + "azure.mgmt.chaos.models.TargetReference": "Microsoft.Chaos.TargetReference", + "azure.mgmt.chaos.models.TargetType": "Microsoft.Chaos.TargetType", + "azure.mgmt.chaos.models.TargetTypeProperties": "Microsoft.Chaos.TargetTypeProperties", + "azure.mgmt.chaos.models.UserAssignedIdentity": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", + "azure.mgmt.chaos.models.Validation": "Microsoft.Chaos.Validation", + "azure.mgmt.chaos.models.ValidationProperties": "Microsoft.Chaos.ValidationProperties", + "azure.mgmt.chaos.models.Workspace": "Microsoft.Chaos.Workspace", + "azure.mgmt.chaos.models.WorkspaceEvaluation": "Microsoft.Chaos.WorkspaceEvaluation", + "azure.mgmt.chaos.models.WorkspaceEvaluationProperties": "Microsoft.Chaos.WorkspaceEvaluationProperties", + "azure.mgmt.chaos.models.WorkspaceProperties": "Microsoft.Chaos.WorkspaceProperties", + "azure.mgmt.chaos.models.WorkspaceUpdate": "Microsoft.Chaos.WorkspaceUpdate", + "azure.mgmt.chaos.models.ZoneResolutionInfo": "Microsoft.Chaos.ZoneResolutionInfo", + "azure.mgmt.chaos.models.ZoneResolutionMapping": "Microsoft.Chaos.ZoneResolutionMapping", + "azure.mgmt.chaos.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.chaos.models.ProvisioningState": "Microsoft.Chaos.ProvisioningState", + "azure.mgmt.chaos.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.chaos.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.chaos.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "azure.mgmt.chaos.models.ExperimentActionType": "Microsoft.Chaos.ExperimentActionType", + "azure.mgmt.chaos.models.SelectorType": "Microsoft.Chaos.SelectorType", + "azure.mgmt.chaos.models.FilterType": "Microsoft.Chaos.FilterType", + "azure.mgmt.chaos.models.TargetReferenceType": "Microsoft.Chaos.TargetReferenceType", + "azure.mgmt.chaos.models.PrivateEndpointServiceConnectionStatus": "Microsoft.Chaos.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.chaos.models.PublicNetworkAccessOption": "Microsoft.Chaos.PublicNetworkAccessOption", + "azure.mgmt.chaos.models.ActionKind": "Microsoft.Chaos.ActionKind", + "azure.mgmt.chaos.models.WorkspaceEvaluationStatus": "Microsoft.Chaos.WorkspaceEvaluationStatus", + "azure.mgmt.chaos.models.RecommendationStatus": "Microsoft.Chaos.RecommendationStatus", + "azure.mgmt.chaos.models.ParameterType": "Microsoft.Chaos.ParameterType", + "azure.mgmt.chaos.models.RunAfterBehavior": "Microsoft.Chaos.RunAfterBehavior", + "azure.mgmt.chaos.models.ActionDependencyType": "Microsoft.Chaos.ActionDependencyType", + "azure.mgmt.chaos.models.ActionLifecycle": "Microsoft.Chaos.ActionLifecycle", + "azure.mgmt.chaos.models.ScenarioRunState": "Microsoft.Chaos.ScenarioRunState", + "azure.mgmt.chaos.models.ScenarioSummaryState": "Microsoft.Chaos.ScenarioSummaryState", + "azure.mgmt.chaos.models.ZoneResolutionMode": "Microsoft.Chaos.ZoneResolutionMode", + "azure.mgmt.chaos.models.ScenarioValidationState": "Microsoft.Chaos.ScenarioValidationState", + "azure.mgmt.chaos.models.PermissionsFixState": "Microsoft.Chaos.PermissionsFixState", + "azure.mgmt.chaos.models.RoleAssignmentStatus": "Microsoft.Chaos.RoleAssignmentStatus", + "azure.mgmt.chaos.operations.CapabilitiesOperations.get": "Microsoft.Chaos.Capabilities.get", + "azure.mgmt.chaos.aio.operations.CapabilitiesOperations.get": "Microsoft.Chaos.Capabilities.get", + "azure.mgmt.chaos.operations.CapabilitiesOperations.create_or_update": "Microsoft.Chaos.Capabilities.createOrUpdate", + "azure.mgmt.chaos.aio.operations.CapabilitiesOperations.create_or_update": "Microsoft.Chaos.Capabilities.createOrUpdate", + "azure.mgmt.chaos.operations.CapabilitiesOperations.delete": "Microsoft.Chaos.Capabilities.delete", + "azure.mgmt.chaos.aio.operations.CapabilitiesOperations.delete": "Microsoft.Chaos.Capabilities.delete", + "azure.mgmt.chaos.operations.CapabilitiesOperations.list": "Microsoft.Chaos.Capabilities.list", + "azure.mgmt.chaos.aio.operations.CapabilitiesOperations.list": "Microsoft.Chaos.Capabilities.list", + "azure.mgmt.chaos.operations.Operations.list_all": "Azure.ResourceManager.Operations.list", + "azure.mgmt.chaos.aio.operations.Operations.list_all": "Azure.ResourceManager.Operations.list", + "azure.mgmt.chaos.operations.TargetsOperations.get": "Microsoft.Chaos.Targets.get", + "azure.mgmt.chaos.aio.operations.TargetsOperations.get": "Microsoft.Chaos.Targets.get", + "azure.mgmt.chaos.operations.TargetsOperations.create_or_update": "Microsoft.Chaos.Targets.createOrUpdate", + "azure.mgmt.chaos.aio.operations.TargetsOperations.create_or_update": "Microsoft.Chaos.Targets.createOrUpdate", + "azure.mgmt.chaos.operations.TargetsOperations.delete": "Microsoft.Chaos.Targets.delete", + "azure.mgmt.chaos.aio.operations.TargetsOperations.delete": "Microsoft.Chaos.Targets.delete", + "azure.mgmt.chaos.operations.TargetsOperations.list": "Microsoft.Chaos.Targets.list", + "azure.mgmt.chaos.aio.operations.TargetsOperations.list": "Microsoft.Chaos.Targets.list", + "azure.mgmt.chaos.operations.CapabilityTypesOperations.get": "Microsoft.Chaos.CapabilityTypes.get", + "azure.mgmt.chaos.aio.operations.CapabilityTypesOperations.get": "Microsoft.Chaos.CapabilityTypes.get", + "azure.mgmt.chaos.operations.CapabilityTypesOperations.list": "Microsoft.Chaos.CapabilityTypes.list", + "azure.mgmt.chaos.aio.operations.CapabilityTypesOperations.list": "Microsoft.Chaos.CapabilityTypes.list", + "azure.mgmt.chaos.operations.ExperimentsOperations.get": "Microsoft.Chaos.Experiments.get", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.get": "Microsoft.Chaos.Experiments.get", + "azure.mgmt.chaos.operations.ExperimentsOperations.begin_create_or_update": "Microsoft.Chaos.Experiments.createOrUpdate", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.begin_create_or_update": "Microsoft.Chaos.Experiments.createOrUpdate", + "azure.mgmt.chaos.operations.ExperimentsOperations.begin_update": "Microsoft.Chaos.Experiments.update", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.begin_update": "Microsoft.Chaos.Experiments.update", + "azure.mgmt.chaos.operations.ExperimentsOperations.begin_delete": "Microsoft.Chaos.Experiments.delete", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.begin_delete": "Microsoft.Chaos.Experiments.delete", + "azure.mgmt.chaos.operations.ExperimentsOperations.list": "Microsoft.Chaos.Experiments.list", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.list": "Microsoft.Chaos.Experiments.list", + "azure.mgmt.chaos.operations.ExperimentsOperations.list_all": "Microsoft.Chaos.Experiments.listAll", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.list_all": "Microsoft.Chaos.Experiments.listAll", + "azure.mgmt.chaos.operations.ExperimentsOperations.begin_cancel": "Microsoft.Chaos.Experiments.cancel", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.begin_cancel": "Microsoft.Chaos.Experiments.cancel", + "azure.mgmt.chaos.operations.ExperimentsOperations.begin_start": "Microsoft.Chaos.Experiments.start", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.begin_start": "Microsoft.Chaos.Experiments.start", + "azure.mgmt.chaos.operations.ExperimentsOperations.get_execution": "Microsoft.Chaos.ExperimentExecutions.getExecution", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.get_execution": "Microsoft.Chaos.ExperimentExecutions.getExecution", + "azure.mgmt.chaos.operations.ExperimentsOperations.list_all_executions": "Microsoft.Chaos.ExperimentExecutions.listAllExecutions", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.list_all_executions": "Microsoft.Chaos.ExperimentExecutions.listAllExecutions", + "azure.mgmt.chaos.operations.ExperimentsOperations.execution_details": "Microsoft.Chaos.ExperimentExecutions.getExecutionDetails", + "azure.mgmt.chaos.aio.operations.ExperimentsOperations.execution_details": "Microsoft.Chaos.ExperimentExecutions.getExecutionDetails", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.get": "Microsoft.Chaos.PrivateAccesses.get", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.get": "Microsoft.Chaos.PrivateAccesses.get", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.begin_create_or_update": "Microsoft.Chaos.PrivateAccesses.createOrUpdate", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.begin_create_or_update": "Microsoft.Chaos.PrivateAccesses.createOrUpdate", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.begin_update": "Microsoft.Chaos.PrivateAccesses.update", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.begin_update": "Microsoft.Chaos.PrivateAccesses.update", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.begin_delete": "Microsoft.Chaos.PrivateAccesses.delete", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.begin_delete": "Microsoft.Chaos.PrivateAccesses.delete", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.list": "Microsoft.Chaos.PrivateAccesses.list", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.list": "Microsoft.Chaos.PrivateAccesses.list", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.list_all": "Microsoft.Chaos.PrivateAccesses.listAll", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.list_all": "Microsoft.Chaos.PrivateAccesses.listAll", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.get_private_link_resources": "Microsoft.Chaos.PrivateAccesses.privateLinkResources", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.get_private_link_resources": "Microsoft.Chaos.PrivateAccesses.privateLinkResources", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.get_a_private_endpoint_connection": "Microsoft.Chaos.PrivateEndpointConnections.getAPrivateEndpointConnection", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.get_a_private_endpoint_connection": "Microsoft.Chaos.PrivateEndpointConnections.getAPrivateEndpointConnection", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.begin_delete_a_private_endpoint_connection": "Microsoft.Chaos.PrivateEndpointConnections.deleteAPrivateEndpointConnection", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.begin_delete_a_private_endpoint_connection": "Microsoft.Chaos.PrivateEndpointConnections.deleteAPrivateEndpointConnection", + "azure.mgmt.chaos.operations.PrivateAccessesOperations.list_private_endpoint_connections": "Microsoft.Chaos.PrivateEndpointConnections.listPrivateEndpointConnections", + "azure.mgmt.chaos.aio.operations.PrivateAccessesOperations.list_private_endpoint_connections": "Microsoft.Chaos.PrivateEndpointConnections.listPrivateEndpointConnections", + "azure.mgmt.chaos.operations.ActionsOperations.get": "Microsoft.Chaos.Actions.get", + "azure.mgmt.chaos.aio.operations.ActionsOperations.get": "Microsoft.Chaos.Actions.get", + "azure.mgmt.chaos.operations.ActionsOperations.list": "Microsoft.Chaos.Actions.list", + "azure.mgmt.chaos.aio.operations.ActionsOperations.list": "Microsoft.Chaos.Actions.list", + "azure.mgmt.chaos.operations.ActionVersionsOperations.get": "Microsoft.Chaos.ActionVersions.get", + "azure.mgmt.chaos.aio.operations.ActionVersionsOperations.get": "Microsoft.Chaos.ActionVersions.get", + "azure.mgmt.chaos.operations.ActionVersionsOperations.list": "Microsoft.Chaos.ActionVersions.list", + "azure.mgmt.chaos.aio.operations.ActionVersionsOperations.list": "Microsoft.Chaos.ActionVersions.list", + "azure.mgmt.chaos.operations.TargetTypesOperations.get": "Microsoft.Chaos.TargetTypes.get", + "azure.mgmt.chaos.aio.operations.TargetTypesOperations.get": "Microsoft.Chaos.TargetTypes.get", + "azure.mgmt.chaos.operations.TargetTypesOperations.list": "Microsoft.Chaos.TargetTypes.list", + "azure.mgmt.chaos.aio.operations.TargetTypesOperations.list": "Microsoft.Chaos.TargetTypes.list", + "azure.mgmt.chaos.operations.OperationStatusesOperations.get": "Microsoft.Chaos.OperationStatuses.get", + "azure.mgmt.chaos.aio.operations.OperationStatusesOperations.get": "Microsoft.Chaos.OperationStatuses.get", + "azure.mgmt.chaos.operations.WorkspacesOperations.get": "Microsoft.Chaos.Workspaces.get", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.get": "Microsoft.Chaos.Workspaces.get", + "azure.mgmt.chaos.operations.WorkspacesOperations.begin_create_or_update": "Microsoft.Chaos.Workspaces.createOrUpdate", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.begin_create_or_update": "Microsoft.Chaos.Workspaces.createOrUpdate", + "azure.mgmt.chaos.operations.WorkspacesOperations.begin_update": "Microsoft.Chaos.Workspaces.update", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.begin_update": "Microsoft.Chaos.Workspaces.update", + "azure.mgmt.chaos.operations.WorkspacesOperations.begin_delete": "Microsoft.Chaos.Workspaces.delete", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.begin_delete": "Microsoft.Chaos.Workspaces.delete", + "azure.mgmt.chaos.operations.WorkspacesOperations.list": "Microsoft.Chaos.Workspaces.list", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.list": "Microsoft.Chaos.Workspaces.list", + "azure.mgmt.chaos.operations.WorkspacesOperations.list_all": "Microsoft.Chaos.Workspaces.listAll", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.list_all": "Microsoft.Chaos.Workspaces.listAll", + "azure.mgmt.chaos.operations.WorkspacesOperations.begin_refresh_recommendations": "Microsoft.Chaos.Workspaces.refreshRecommendations", + "azure.mgmt.chaos.aio.operations.WorkspacesOperations.begin_refresh_recommendations": "Microsoft.Chaos.Workspaces.refreshRecommendations", + "azure.mgmt.chaos.operations.DiscoveredResourcesOperations.get": "Microsoft.Chaos.DiscoveredResources.get", + "azure.mgmt.chaos.aio.operations.DiscoveredResourcesOperations.get": "Microsoft.Chaos.DiscoveredResources.get", + "azure.mgmt.chaos.operations.DiscoveredResourcesOperations.list_by_workspace": "Microsoft.Chaos.DiscoveredResources.listByWorkspace", + "azure.mgmt.chaos.aio.operations.DiscoveredResourcesOperations.list_by_workspace": "Microsoft.Chaos.DiscoveredResources.listByWorkspace", + "azure.mgmt.chaos.operations.ScenariosOperations.get": "Microsoft.Chaos.Scenarios.get", + "azure.mgmt.chaos.aio.operations.ScenariosOperations.get": "Microsoft.Chaos.Scenarios.get", + "azure.mgmt.chaos.operations.ScenariosOperations.create_or_update": "Microsoft.Chaos.Scenarios.createOrUpdate", + "azure.mgmt.chaos.aio.operations.ScenariosOperations.create_or_update": "Microsoft.Chaos.Scenarios.createOrUpdate", + "azure.mgmt.chaos.operations.ScenariosOperations.delete": "Microsoft.Chaos.Scenarios.delete", + "azure.mgmt.chaos.aio.operations.ScenariosOperations.delete": "Microsoft.Chaos.Scenarios.delete", + "azure.mgmt.chaos.operations.ScenariosOperations.list_all": "Microsoft.Chaos.Scenarios.listAll", + "azure.mgmt.chaos.aio.operations.ScenariosOperations.list_all": "Microsoft.Chaos.Scenarios.listAll", + "azure.mgmt.chaos.operations.ScenarioRunsOperations.get": "Microsoft.Chaos.ScenarioRuns.get", + "azure.mgmt.chaos.aio.operations.ScenarioRunsOperations.get": "Microsoft.Chaos.ScenarioRuns.get", + "azure.mgmt.chaos.operations.ScenarioRunsOperations.list_all": "Microsoft.Chaos.ScenarioRuns.listAll", + "azure.mgmt.chaos.aio.operations.ScenarioRunsOperations.list_all": "Microsoft.Chaos.ScenarioRuns.listAll", + "azure.mgmt.chaos.operations.ScenarioRunsOperations.cancel": "Microsoft.Chaos.ScenarioRuns.cancel", + "azure.mgmt.chaos.aio.operations.ScenarioRunsOperations.cancel": "Microsoft.Chaos.ScenarioRuns.cancel", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.get": "Microsoft.Chaos.ScenarioConfigurations.get", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.get": "Microsoft.Chaos.ScenarioConfigurations.get", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.begin_create_or_update": "Microsoft.Chaos.ScenarioConfigurations.createOrUpdate", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.begin_create_or_update": "Microsoft.Chaos.ScenarioConfigurations.createOrUpdate", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.begin_delete": "Microsoft.Chaos.ScenarioConfigurations.delete", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.begin_delete": "Microsoft.Chaos.ScenarioConfigurations.delete", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.list_all": "Microsoft.Chaos.ScenarioConfigurations.listAll", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.list_all": "Microsoft.Chaos.ScenarioConfigurations.listAll", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.execute": "Microsoft.Chaos.ScenarioConfigurations.execute", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.execute": "Microsoft.Chaos.ScenarioConfigurations.execute", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.begin_validate": "Microsoft.Chaos.ScenarioConfigurations.validate", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.begin_validate": "Microsoft.Chaos.ScenarioConfigurations.validate", + "azure.mgmt.chaos.operations.ScenarioConfigurationsOperations.begin_fix_resource_permissions": "Microsoft.Chaos.ScenarioConfigurations.fixResourcePermissions", + "azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations.begin_fix_resource_permissions": "Microsoft.Chaos.ScenarioConfigurations.fixResourcePermissions" + } +} \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/azure/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py index 16279ccfa735..a3cf37ea9cc0 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__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 ._chaos_management_client import ChaosManagementClient # type: ignore +from ._client import ChaosManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_client.py similarity index 59% rename from sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py rename to sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_client.py index 8fe78c5e1a41..dd9ad5d578fc 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_client.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. # -------------------------------------------------------------------------- @@ -17,63 +17,103 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import ChaosManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( + ActionVersionsOperations, + ActionsOperations, CapabilitiesOperations, CapabilityTypesOperations, + DiscoveredResourcesOperations, ExperimentsOperations, OperationStatusesOperations, Operations, + PrivateAccessesOperations, + ScenarioConfigurationsOperations, + ScenarioRunsOperations, + ScenariosOperations, TargetTypesOperations, TargetsOperations, + WorkspacesOperations, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential class ChaosManagementClient: # pylint: disable=too-many-instance-attributes """Chaos Management Client. + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: azure.mgmt.chaos.operations.CapabilitiesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.chaos.operations.Operations + :ivar targets: TargetsOperations operations + :vartype targets: azure.mgmt.chaos.operations.TargetsOperations + :ivar capability_types: CapabilityTypesOperations operations + :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations :ivar experiments: ExperimentsOperations operations :vartype experiments: azure.mgmt.chaos.operations.ExperimentsOperations - :ivar operation_statuses: OperationStatusesOperations operations - :vartype operation_statuses: azure.mgmt.chaos.operations.OperationStatusesOperations + :ivar private_accesses: PrivateAccessesOperations operations + :vartype private_accesses: azure.mgmt.chaos.operations.PrivateAccessesOperations + :ivar actions: ActionsOperations operations + :vartype actions: azure.mgmt.chaos.operations.ActionsOperations + :ivar action_versions: ActionVersionsOperations operations + :vartype action_versions: azure.mgmt.chaos.operations.ActionVersionsOperations :ivar target_types: TargetTypesOperations operations :vartype target_types: azure.mgmt.chaos.operations.TargetTypesOperations - :ivar capability_types: CapabilityTypesOperations operations - :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations - :ivar targets: TargetsOperations operations - :vartype targets: azure.mgmt.chaos.operations.TargetsOperations - :ivar capabilities: CapabilitiesOperations operations - :vartype capabilities: azure.mgmt.chaos.operations.CapabilitiesOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: azure.mgmt.chaos.operations.OperationStatusesOperations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.chaos.operations.WorkspacesOperations + :ivar discovered_resources: DiscoveredResourcesOperations operations + :vartype discovered_resources: azure.mgmt.chaos.operations.DiscoveredResourcesOperations + :ivar scenarios: ScenariosOperations operations + :vartype scenarios: azure.mgmt.chaos.operations.ScenariosOperations + :ivar scenario_runs: ScenarioRunsOperations operations + :vartype scenario_runs: azure.mgmt.chaos.operations.ScenarioRunsOperations + :ivar scenario_configurations: ScenarioConfigurationsOperations operations + :vartype scenario_configurations: azure.mgmt.chaos.operations.ScenarioConfigurationsOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2025-01-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-05-01-preview". Default value is "2026-05-01-preview". Note that overriding this default + value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + self, + credential: "TokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = ChaosManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) _policies = kwargs.pop("policies", None) @@ -94,31 +134,44 @@ 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.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capability_types = CapabilityTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_statuses = OperationStatusesOperations( + self.private_accesses = PrivateAccessesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.actions = ActionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_versions = ActionVersionsOperations(self._client, self._config, self._serialize, self._deserialize) self.target_types = TargetTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.capability_types = CapabilityTypesOperations( + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.discovered_resources = DiscoveredResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scenarios = ScenariosOperations(self._client, self._config, self._serialize, self._deserialize) + self.scenario_runs = ScenarioRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scenario_configurations = ScenarioConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations(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 @@ -131,7 +184,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/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py index 61058b403d1d..38a1e2471ae4 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,6 +14,7 @@ from ._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -23,17 +24,30 @@ class ChaosManagementClientConfiguration: # pylint: disable=too-many-instance-a Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2025-01-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-05-01-preview". Default value is "2026-05-01-preview". Note that overriding this default + value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-01-01") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2026-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +56,8 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-chaos/{}".format(VERSION)) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_patch.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_patch.py index 17dbc073e01b..ea765788358a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_patch.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_patch.py @@ -1,32 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_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/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/model_base.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/model_base.py new file mode 100644 index 000000000000..eef4e52ed1a0 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/model_base.py @@ -0,0 +1,1459 @@ +# 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 +from typing_extensions import Self +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 + +_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) + + +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 = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + 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 + } + ) + super().__init__(dict_to_pass) + + def _init_from_xml(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] = {} + model_meta = getattr(self, "_xml", {}) + existed_attr_keys: list[str] = [] + + 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): + # unwrapped array could either use prop items meta/prop meta + _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, it should only have one element + 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() + } + 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, + 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._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) + 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) + + 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, + 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, + 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 + 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/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/serialization.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/serialization.py index f5187701d7be..81ec1de5922b 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_utils/serialization.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_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. # -------------------------------------------------------------------------- @@ -21,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -31,7 +30,6 @@ Mapping, Callable, MutableMapping, - List, ) try: @@ -229,12 +227,12 @@ class Model: serialization and deserialization. """ - _subtype_map: Dict[str, Dict[str, Any]] = {} - _attribute_map: Dict[str, Dict[str, Any]] = {} - _validation: Dict[str, Dict[str, Any]] = {} + _subtype_map: dict[str, dict[str, Any]] = {} + _attribute_map: dict[str, dict[str, Any]] = {} + _validation: dict[str, dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -311,7 +309,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -380,7 +378,7 @@ def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: def from_dict( cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, ) -> Self: """Parse a dict using given key extractor return a model. @@ -414,7 +412,7 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod @@ -528,7 +526,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -579,7 +577,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -789,7 +787,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -823,13 +821,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1184,7 +1189,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1386,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1759,7 +1764,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1785,7 +1790,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_validation.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py index 48944bf3938a..fd5e9189cf06 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0b1" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py index 8729c3e02212..4429c835dea9 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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 ._chaos_management_client import ChaosManagementClient # type: ignore +from ._client import ChaosManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_client.py similarity index 60% rename from sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py rename to sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_client.py index faeaf860b336..7e2b16cf8c65 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_client.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. # -------------------------------------------------------------------------- @@ -17,63 +17,104 @@ 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 ChaosManagementClientConfiguration from .operations import ( + ActionVersionsOperations, + ActionsOperations, CapabilitiesOperations, CapabilityTypesOperations, + DiscoveredResourcesOperations, ExperimentsOperations, OperationStatusesOperations, Operations, + PrivateAccessesOperations, + ScenarioConfigurationsOperations, + ScenarioRunsOperations, + ScenariosOperations, TargetTypesOperations, TargetsOperations, + WorkspacesOperations, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential class ChaosManagementClient: # pylint: disable=too-many-instance-attributes """Chaos Management Client. + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: azure.mgmt.chaos.aio.operations.CapabilitiesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.chaos.aio.operations.Operations + :ivar targets: TargetsOperations operations + :vartype targets: azure.mgmt.chaos.aio.operations.TargetsOperations + :ivar capability_types: CapabilityTypesOperations operations + :vartype capability_types: azure.mgmt.chaos.aio.operations.CapabilityTypesOperations :ivar experiments: ExperimentsOperations operations :vartype experiments: azure.mgmt.chaos.aio.operations.ExperimentsOperations - :ivar operation_statuses: OperationStatusesOperations operations - :vartype operation_statuses: azure.mgmt.chaos.aio.operations.OperationStatusesOperations + :ivar private_accesses: PrivateAccessesOperations operations + :vartype private_accesses: azure.mgmt.chaos.aio.operations.PrivateAccessesOperations + :ivar actions: ActionsOperations operations + :vartype actions: azure.mgmt.chaos.aio.operations.ActionsOperations + :ivar action_versions: ActionVersionsOperations operations + :vartype action_versions: azure.mgmt.chaos.aio.operations.ActionVersionsOperations :ivar target_types: TargetTypesOperations operations :vartype target_types: azure.mgmt.chaos.aio.operations.TargetTypesOperations - :ivar capability_types: CapabilityTypesOperations operations - :vartype capability_types: azure.mgmt.chaos.aio.operations.CapabilityTypesOperations - :ivar targets: TargetsOperations operations - :vartype targets: azure.mgmt.chaos.aio.operations.TargetsOperations - :ivar capabilities: CapabilitiesOperations operations - :vartype capabilities: azure.mgmt.chaos.aio.operations.CapabilitiesOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: azure.mgmt.chaos.aio.operations.OperationStatusesOperations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.chaos.aio.operations.WorkspacesOperations + :ivar discovered_resources: DiscoveredResourcesOperations operations + :vartype discovered_resources: azure.mgmt.chaos.aio.operations.DiscoveredResourcesOperations + :ivar scenarios: ScenariosOperations operations + :vartype scenarios: azure.mgmt.chaos.aio.operations.ScenariosOperations + :ivar scenario_runs: ScenarioRunsOperations operations + :vartype scenario_runs: azure.mgmt.chaos.aio.operations.ScenarioRunsOperations + :ivar scenario_configurations: ScenarioConfigurationsOperations operations + :vartype scenario_configurations: + azure.mgmt.chaos.aio.operations.ScenarioConfigurationsOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2025-01-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-05-01-preview". Default value is "2026-05-01-preview". Note that overriding this default + value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = ChaosManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) _policies = kwargs.pop("policies", None) @@ -95,26 +136,39 @@ 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.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.capability_types = CapabilityTypesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation_statuses = OperationStatusesOperations( + self.private_accesses = PrivateAccessesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.actions = ActionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_versions = ActionVersionsOperations(self._client, self._config, self._serialize, self._deserialize) self.target_types = TargetTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.capability_types = CapabilityTypesOperations( + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.discovered_resources = DiscoveredResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scenarios = ScenariosOperations(self._client, self._config, self._serialize, self._deserialize) + self.scenario_runs = ScenarioRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scenario_configurations = ScenarioConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations(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. @@ -122,7 +176,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 @@ -135,7 +189,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/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py index be653c851660..ce7644a94731 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,6 +14,7 @@ from .._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -23,17 +24,30 @@ class ChaosManagementClientConfiguration: # pylint: disable=too-many-instance-a Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2025-01-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-05-01-preview". Default value is "2026-05-01-preview". Note that overriding this default + value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-01-01") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2026-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +56,8 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-chaos/{}".format(VERSION)) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_patch.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_patch.py index 17dbc073e01b..ea765788358a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_patch.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_patch.py @@ -1,32 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/__init__.py index 66eddae45563..f4cff5a39c7c 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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 @@ -12,26 +12,42 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import CapabilitiesOperations # type: ignore from ._operations import Operations # type: ignore -from ._experiments_operations import ExperimentsOperations # type: ignore -from ._operation_statuses_operations import OperationStatusesOperations # type: ignore -from ._target_types_operations import TargetTypesOperations # type: ignore -from ._capability_types_operations import CapabilityTypesOperations # type: ignore -from ._targets_operations import TargetsOperations # type: ignore -from ._capabilities_operations import CapabilitiesOperations # type: ignore +from ._operations import TargetsOperations # type: ignore +from ._operations import CapabilityTypesOperations # type: ignore +from ._operations import ExperimentsOperations # type: ignore +from ._operations import PrivateAccessesOperations # type: ignore +from ._operations import ActionsOperations # type: ignore +from ._operations import ActionVersionsOperations # type: ignore +from ._operations import TargetTypesOperations # type: ignore +from ._operations import OperationStatusesOperations # type: ignore +from ._operations import WorkspacesOperations # type: ignore +from ._operations import DiscoveredResourcesOperations # type: ignore +from ._operations import ScenariosOperations # type: ignore +from ._operations import ScenarioRunsOperations # type: ignore +from ._operations import ScenarioConfigurationsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "CapabilitiesOperations", "Operations", + "TargetsOperations", + "CapabilityTypesOperations", "ExperimentsOperations", - "OperationStatusesOperations", + "PrivateAccessesOperations", + "ActionsOperations", + "ActionVersionsOperations", "TargetTypesOperations", - "CapabilityTypesOperations", - "TargetsOperations", - "CapabilitiesOperations", + "OperationStatusesOperations", + "WorkspacesOperations", + "DiscoveredResourcesOperations", + "ScenariosOperations", + "ScenarioRunsOperations", + "ScenarioConfigurationsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py deleted file mode 100644 index 64a57ac8f440..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py +++ /dev/null @@ -1,486 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._capabilities_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`capabilities` 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") - self._config: ChaosManagementClientConfiguration = 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_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Capability"]: - """Get a list of Capability resources that extend a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Capability] - :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.CapabilityListResult] = 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_list_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - **kwargs: Any - ) -> _models.Capability: - """Get a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :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.Capability] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: _models.Capability, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Capability - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: Union[_models.Capability, IO[bytes]], - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Is either a Capability type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Capability or IO[bytes] - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :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 {}) - - 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.Capability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Capability") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - **kwargs: Any - ) -> None: - """Delete a Capability that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_operations.py deleted file mode 100644 index 7ace6ce45966..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_operations.py +++ /dev/null @@ -1,202 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._capability_types_operations import build_get_request, build_list_request -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CapabilityTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`capability_types` 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") - self._config: ChaosManagementClientConfiguration = 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, location: str, target_type_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.CapabilityType"]: - """Get a list of Capability Type resources for given Target Type and location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either CapabilityType or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.CapabilityType] - :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.CapabilityTypeListResult] = 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_list_request( - location=location, - target_type_name=target_type_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CapabilityTypeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, location: str, target_type_name: str, capability_type_name: str, **kwargs: Any - ) -> _models.CapabilityType: - """Get a Capability Type resource for given Target Type and location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :param capability_type_name: String that represents a Capability Type resource name. Required. - :type capability_type_name: str - :return: CapabilityType or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.CapabilityType - :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.CapabilityType] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - target_type_name=target_type_name, - capability_type_name=capability_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapabilityType", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py deleted file mode 100644 index b587ee1ab7bd..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py +++ /dev/null @@ -1,1249 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._experiments_operations import ( - build_cancel_request, - build_create_or_update_request, - build_delete_request, - build_execution_details_request, - build_get_execution_request, - build_get_request, - build_list_all_executions_request, - build_list_all_request, - build_list_request, - build_start_request, - build_update_request, -) -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ExperimentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`experiments` 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") - self._config: ChaosManagementClientConfiguration = 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_all( - self, running: Optional[bool] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Experiment"]: - """Get a list of Experiment resources in a subscription. - - :param running: Optional value that indicates whether to filter results based on if the - Experiment is currently running. If null, then the results will not be filtered. Default value - is None. - :type running: bool - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Experiment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Experiment] - :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.ExperimentListResult] = 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_list_all_request( - subscription_id=self._config.subscription_id, - running=running, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, - resource_group_name: str, - running: Optional[bool] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Experiment"]: - """Get a list of Experiment resources in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param running: Optional value that indicates whether to filter results based on if the - Experiment is currently running. If null, then the results will not be filtered. Default value - is None. - :type running: bool - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Experiment or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Experiment] - :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.ExperimentListResult] = 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - running=running, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> _models.Experiment: - """Get a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :return: Experiment or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Experiment - :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.Experiment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Experiment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - experiment_name: str, - resource: Union[_models.Experiment, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Experiment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: _models.Experiment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Experiment - :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 Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: Union[_models.Experiment, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Is either a Experiment type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Experiment or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :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.Experiment] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - resource=resource, - 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("Experiment", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Experiment].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Experiment]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - experiment_name: str, - properties: Union[_models.ExperimentUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "ExperimentUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: _models.ExperimentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Required. - :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate - :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 Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Required. - :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 Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: Union[_models.ExperimentUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Is either a - ExperimentUpdate type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Experiment or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] - :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.Experiment] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - properties=properties, - 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("Experiment", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Experiment].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Experiment]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_delete_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Delete a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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 _cancel_initial( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Cancel a running Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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._cancel_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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_all_executions( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ExperimentExecution"]: - """Get a list of executions of an Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :return: An iterator like instance of either ExperimentExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] - :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.ExperimentExecutionListResult] = 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_list_all_executions_request( - resource_group_name=resource_group_name, - experiment_name=experiment_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), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentExecutionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_execution( - self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any - ) -> _models.ExperimentExecution: - """Get an execution of an Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param execution_id: GUID that represents a Experiment execution detail. Required. - :type execution_id: str - :return: ExperimentExecution or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentExecution - :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.ExperimentExecution] = kwargs.pop("cls", None) - - _request = build_get_execution_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - execution_id=execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentExecution", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def execution_details( - self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any - ) -> _models.ExperimentExecutionDetails: - """Execution details of an experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param execution_id: GUID that represents a Experiment execution detail. Required. - :type execution_id: str - :return: ExperimentExecutionDetails or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentExecutionDetails - :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.ExperimentExecutionDetails] = kwargs.pop("cls", None) - - _request = build_execution_details_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - execution_id=execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentExecutionDetails", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _start_initial( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_start_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Start a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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._start_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[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 diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py deleted file mode 100644 index 6fb1d6d55fb1..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._operation_statuses_operations import build_get_request -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class OperationStatusesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`operation_statuses` 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") - self._config: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: - """Returns the current status of an async operation. - - :param location: The name of the Azure region. Required. - :type location: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.OperationStatusResult - :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.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py index e695db14945b..599e897aeacc 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py @@ -1,12 +1,15 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -17,21 +20,622 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_all_request +from ..._validation import api_version_validation +from ...operations._operations import ( + build_action_versions_get_request, + build_action_versions_list_request, + build_actions_get_request, + build_actions_list_request, + build_capabilities_create_or_update_request, + build_capabilities_delete_request, + build_capabilities_get_request, + build_capabilities_list_request, + build_capability_types_get_request, + build_capability_types_list_request, + build_discovered_resources_get_request, + build_discovered_resources_list_by_workspace_request, + build_experiments_cancel_request, + build_experiments_create_or_update_request, + build_experiments_delete_request, + build_experiments_execution_details_request, + build_experiments_get_execution_request, + build_experiments_get_request, + build_experiments_list_all_executions_request, + build_experiments_list_all_request, + build_experiments_list_request, + build_experiments_start_request, + build_experiments_update_request, + build_operation_statuses_get_request, + build_operations_list_all_request, + build_private_accesses_create_or_update_request, + build_private_accesses_delete_a_private_endpoint_connection_request, + build_private_accesses_delete_request, + build_private_accesses_get_a_private_endpoint_connection_request, + build_private_accesses_get_private_link_resources_request, + build_private_accesses_get_request, + build_private_accesses_list_all_request, + build_private_accesses_list_private_endpoint_connections_request, + build_private_accesses_list_request, + build_private_accesses_update_request, + build_scenario_configurations_create_or_update_request, + build_scenario_configurations_delete_request, + build_scenario_configurations_execute_request, + build_scenario_configurations_fix_resource_permissions_request, + build_scenario_configurations_get_request, + build_scenario_configurations_list_all_request, + build_scenario_configurations_validate_request, + build_scenario_runs_cancel_request, + build_scenario_runs_get_request, + build_scenario_runs_list_all_request, + build_scenarios_create_or_update_request, + build_scenarios_delete_request, + build_scenarios_get_request, + build_scenarios_list_all_request, + build_target_types_get_request, + build_target_types_list_request, + build_targets_create_or_update_request, + build_targets_delete_request, + build_targets_get_request, + build_targets_list_request, + build_workspaces_create_or_update_request, + build_workspaces_delete_request, + build_workspaces_get_request, + build_workspaces_list_all_request, + build_workspaces_list_request, + build_workspaces_refresh_recommendations_request, + build_workspaces_update_request, +) from .._configuration import ChaosManagementClientConfiguration +JSON = MutableMapping[str, Any] T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +class CapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`capabilities` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> _models.Capability: + """Get a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :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.Capability] = kwargs.pop("cls", None) + + _request = build_capabilities_get_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: _models.Capability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Capability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: Union[_models.Capability, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Is one of the following types: + Capability, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Capability or JSON or IO[bytes] + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_capabilities_create_or_update_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> None: + """Delete a Capability that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_capabilities_delete_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Capability"]: + """Get a list of Capability resources that extend a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Capability + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = 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_capabilities_list_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Capability], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) class Operations: @@ -44,8 +648,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") @@ -57,15 +659,14 @@ def __init__(self, *args, **kwargs) -> None: def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """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.chaos.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, @@ -78,12 +679,17 @@ def list_all(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_all_request( - api_version=api_version, + _request = build_operations_list_all_request( + 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 @@ -98,16 +704,24 @@ def prepare_request(next_link=None): _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" + 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) @@ -120,9 +734,7440 @@ 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + +class TargetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`targets` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> _models.Target: + """Get a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :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.Target] = kwargs.pop("cls", None) + + _request = build_targets_get_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Target, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: _models.Target, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Target + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: Union[_models.Target, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Is one of the following types: + Target, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Target or JSON or IO[bytes] + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Target] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_targets_create_or_update_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Target, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> None: + """Delete a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_targets_delete_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Target"]: + """Get a list of Target resources that extend a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Target + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Target] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Target]] = 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_targets_list_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Target], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CapabilityTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`capability_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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, location: str, target_type_name: str, capability_type_name: str, **kwargs: Any + ) -> _models.CapabilityType: + """Get a Capability Type resource for given Target Type and location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :param capability_type_name: String that represents a Capability Type resource name. Required. + :type capability_type_name: str + :return: CapabilityType. The CapabilityType is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.CapabilityType + :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.CapabilityType] = kwargs.pop("cls", None) + + _request = build_capability_types_get_request( + location=location, + target_type_name=target_type_name, + capability_type_name=capability_type_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CapabilityType, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, target_type_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.CapabilityType"]: + """Get a list of Capability Type resources for given Target Type and location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of CapabilityType + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.CapabilityType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityType]] = 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_capability_types_list_request( + location=location, + target_type_name=target_type_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.CapabilityType], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ExperimentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`experiments` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> _models.Experiment: + """Get a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: Experiment. The Experiment is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Experiment + :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.Experiment] = kwargs.pop("cls", None) + + _request = build_experiments_get_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Experiment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + experiment_name: str, + resource: Union[_models.Experiment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_experiments_create_or_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: _models.Experiment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Experiment + :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 Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: 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 Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: Union[_models.Experiment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Is one of the following types: + Experiment, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Experiment or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Experiment, 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.Experiment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + experiment_name: str, + properties: Union[_models.ExperimentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_experiments_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: _models.ExperimentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate + :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 Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :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: An instance of AsyncLROPoller that returns Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :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 Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: Union[_models.ExperimentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Is one of the + following types: ExperimentUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Experiment. The Experiment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Experiment, 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.Experiment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_delete_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + *, + running: Optional[bool] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Experiment"]: + """Get a list of Experiment resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. Default value + is None. + :paramtype running: bool + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Experiment + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Experiment]] = 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_experiments_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + running=running, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Experiment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_all( + self, *, running: Optional[bool] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Experiment"]: + """Get a list of Experiment resources in a subscription. + + :keyword running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. Default value + is None. + :paramtype running: bool + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Experiment + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Experiment]] = 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_experiments_list_all_request( + subscription_id=self._config.subscription_id, + running=running, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Experiment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _cancel_initial( + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_cancel_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Cancel a running Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cancel_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _start_initial( + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_start_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Start a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get_execution( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecution: + """Get an execution of an Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_id: str + :return: ExperimentExecution. The ExperimentExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ExperimentExecution + :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.ExperimentExecution] = kwargs.pop("cls", None) + + _request = build_experiments_get_execution_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + execution_id=execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExperimentExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_all_executions( + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ExperimentExecution"]: + """Get a list of executions of an Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An iterator like instance of ExperimentExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExperimentExecution]] = 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_experiments_list_all_executions_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.ExperimentExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def execution_details( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecutionDetails: + """Execution details of an experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_id: str + :return: ExperimentExecutionDetails. The ExperimentExecutionDetails is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.ExperimentExecutionDetails + :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.ExperimentExecutionDetails] = kwargs.pop("cls", None) + + _request = build_experiments_execution_details_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + execution_id=execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExperimentExecutionDetails, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`private_accesses` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> _models.PrivateAccess: + """Get a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: PrivateAccess. The PrivateAccess is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :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.PrivateAccess] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateAccess, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + private_access_name: str, + resource: Union[_models.PrivateAccess, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_accesses_create_or_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: _models.PrivateAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.PrivateAccess + :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 PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: 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 PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: Union[_models.PrivateAccess, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Is one of the following + types: PrivateAccess, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.PrivateAccess or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateAccess] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateAccess, 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.PrivateAccess].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateAccess]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + private_access_name: str, + properties: Union[_models.PrivateAccessPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_accesses_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: _models.PrivateAccessPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :type properties: ~azure.mgmt.chaos.models.PrivateAccessPatch + :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 PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :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: An instance of AsyncLROPoller that returns PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :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 PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: Union[_models.PrivateAccessPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Is one of the following types: + PrivateAccessPatch, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.PrivateAccessPatch or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateAccess. The PrivateAccess is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateAccess] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateAccess, 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.PrivateAccess].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateAccess]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_accesses_delete_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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, private_access_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateAccess"]: + """Get a list of private access resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of PrivateAccess + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateAccess]] = 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_private_accesses_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.PrivateAccess], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_all( + self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateAccess"]: + """Get a list of private access resources in a subscription. + + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of PrivateAccess + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateAccess]] = 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_private_accesses_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.PrivateAccess], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_private_link_resources( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateLinkResourceListResult + :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_private_link_resources_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_accesses_delete_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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_a_private_endpoint_connection( # pylint: disable=name-too-long + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = 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_private_accesses_list_private_endpoint_connections_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`actions` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={"2026-05-01-preview": ["api_version", "subscription_id", "location", "action_name", "accept"]}, + api_versions_list=["2026-05-01-preview"], + ) + async def get(self, location: str, action_name: str, **kwargs: Any) -> _models.Action: + """Get an Action resource for a given location. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :return: Action. The Action is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Action + :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.Action] = kwargs.pop("cls", None) + + _request = build_actions_get_request( + location=location, + action_name=action_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Action, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, location: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Action"]: + """Get a list of Action resources for a given location. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Action + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Action] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Action]] = 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_actions_list_request( + location=location, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Action], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ActionVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`action_versions` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "action_name", + "version_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get(self, location: str, action_name: str, version_name: str, **kwargs: Any) -> _models.ActionVersion: + """Get an Action Version resource for a given location and action. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :param version_name: String that represents an Action Version resource name. Required. + :type version_name: str + :return: ActionVersion. The ActionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ActionVersion + :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.ActionVersion] = kwargs.pop("cls", None) + + _request = build_action_versions_get_request( + location=location, + action_name=action_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ActionVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "action_name", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, location: str, action_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ActionVersion"]: + """Get a list of Action Version resources for a given location and action. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ActionVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ActionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ActionVersion]] = 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_action_versions_list_request( + location=location, + action_name=action_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.ActionVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TargetTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`target_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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, target_type_name: str, **kwargs: Any) -> _models.TargetType: + """Get a Target Type resources for given location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :return: TargetType. The TargetType is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.TargetType + :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.TargetType] = kwargs.pop("cls", None) + + _request = build_target_types_get_request( + location=location, + target_type_name=target_type_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TargetType, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.TargetType"]: + """Get a list of Target Type resources for given location. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of TargetType + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.TargetType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TargetType]] = 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_target_types_list_request( + location=location, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.TargetType], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OperationStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`operation_statuses` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The location name. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.OperationStatusResult + :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.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_statuses_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`workspaces` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: + """Get a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: Workspace. The Workspace is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Workspace + :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.Workspace] = kwargs.pop("cls", None) + + _request = build_workspaces_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Workspace, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _create_or_update_initial( + self, + resource_group_name: str, + workspace_name: str, + resource: Union[_models.Workspace, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspaces_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Workspace + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: 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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: Union[_models.Workspace, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Is one of the following types: + Workspace, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Workspace or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Workspace, 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.Workspace].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _update_initial( + self, + resource_group_name: str, + workspace_name: str, + properties: Union[_models.WorkspaceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspaces_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: _models.WorkspaceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :type properties: ~azure.mgmt.chaos.models.WorkspaceUpdate + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :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: An instance of AsyncLROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: Union[_models.WorkspaceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Is one of the + following types: WorkspaceUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.WorkspaceUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Workspace, 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.Workspace].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _delete_initial( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspaces_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, resource_group_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Workspace"]: + """Get a list of Workspace resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Workspace + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Workspace]] = 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_workspaces_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Workspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Workspace"]: + """Get a list of all Workspace resources in a subscription. + + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Workspace + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Workspace]] = 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_workspaces_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Workspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _refresh_recommendations_initial( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspaces_refresh_recommendations_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_refresh_recommendations( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.WorkspaceEvaluation]: + """Refreshes recommendation status for all scenarios in a given workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An instance of AsyncLROPoller that returns WorkspaceEvaluation. The + WorkspaceEvaluation is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.WorkspaceEvaluation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkspaceEvaluation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_recommendations_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.WorkspaceEvaluation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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.WorkspaceEvaluation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WorkspaceEvaluation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DiscoveredResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`discovered_resources` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "discovered_resource_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get( + self, resource_group_name: str, workspace_name: str, discovered_resource_name: str, **kwargs: Any + ) -> _models.DiscoveredResource: + """Get a discovered resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param discovered_resource_name: Name of the discovered resource. Required. + :type discovered_resource_name: str + :return: DiscoveredResource. The DiscoveredResource is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.DiscoveredResource + :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.DiscoveredResource] = kwargs.pop("cls", None) + + _request = build_discovered_resources_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + discovered_resource_name=discovered_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiscoveredResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_by_workspace( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DiscoveredResource"]: + """Get a list of discovered resources for a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An iterator like instance of DiscoveredResource + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.DiscoveredResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiscoveredResource]] = 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_discovered_resources_list_by_workspace_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.DiscoveredResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ScenariosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`scenarios` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get( + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> _models.Scenario: + """Get a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :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.Scenario] = kwargs.pop("cls", None) + + _request = build_scenarios_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Scenario, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: _models.Scenario, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.chaos.models.Scenario + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: Union[_models.Scenario, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Is one of the following types: Scenario, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Scenario or JSON or IO[bytes] + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Scenario] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_scenarios_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Scenario, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def delete(self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any) -> None: + """Delete a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_scenarios_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Scenario"]: + """Get a list of scenarios. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An iterator like instance of Scenario + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Scenario] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Scenario]] = 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_scenarios_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.Scenario], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ScenarioRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`scenario_runs` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "run_id", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get( + self, resource_group_name: str, workspace_name: str, scenario_name: str, run_id: str, **kwargs: Any + ) -> _models.ScenarioRun: + """Get a scenario run. + + Get a scenario run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param run_id: The name of the ScenarioRun. Required. + :type run_id: str + :return: ScenarioRun. The ScenarioRun is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ScenarioRun + :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.ScenarioRun] = kwargs.pop("cls", None) + + _request = build_scenario_runs_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + run_id=run_id, + 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, 202]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ScenarioRun, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ScenarioRun"]: + """Get a list of scenario runs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: An iterator like instance of ScenarioRun + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ScenarioRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ScenarioRun]] = 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_scenario_runs_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.ScenarioRun], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "run_id", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def cancel( + self, resource_group_name: str, workspace_name: str, scenario_name: str, run_id: str, **kwargs: Any + ) -> None: + """Cancel the currently running scenario execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param run_id: The name of the ScenarioRun. Required. + :type run_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_scenario_runs_cancel_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + run_id=run_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class ScenarioConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`scenario_configurations` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def get( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> _models.ScenarioConfiguration: + """Get a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: ScenarioConfiguration. The ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ScenarioConfiguration + :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.ScenarioConfiguration] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ScenarioConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _create_or_update_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: Union[_models.ScenarioConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_scenario_configurations_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: _models.ScenarioConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.chaos.models.ScenarioConfiguration + :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 ScenarioConfiguration. The + ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 ScenarioConfiguration. The + ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ScenarioConfiguration. The + ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: Union[_models.ScenarioConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Is one of the following types: + ScenarioConfiguration, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.ScenarioConfiguration or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ScenarioConfiguration. The + ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScenarioConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ScenarioConfiguration, 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.ScenarioConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ScenarioConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _delete_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_delete( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ScenarioConfiguration"]: + """Get a list of scenario definitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: An iterator like instance of ScenarioConfiguration + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ScenarioConfiguration]] = 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_scenario_configurations_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.ScenarioConfiguration], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def execute( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> None: + """Execute the scenario execution with the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_execute_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _validate_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_validate_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_validate( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.Validation]: + """Validate the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: An instance of AsyncLROPoller that returns Validation. The Validation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.Validation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Validation] = 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._validate_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Validation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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.Validation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Validation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def _fix_resource_permissions_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[Union[_models.FixResourcePermissionsRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_scenario_configurations_fix_resource_permissions_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[_models.FixResourcePermissionsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.chaos.models.FixResourcePermissionsRequest + :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 PermissionsFix. The PermissionsFix is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: 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 PermissionsFix. The PermissionsFix is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PermissionsFix. The PermissionsFix is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + async def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[Union[_models.FixResourcePermissionsRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Is one of the following types: FixResourcePermissionsRequest, JSON, IO[bytes] + Default value is None. + :type body: ~azure.mgmt.chaos.models.FixResourcePermissionsRequest or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PermissionsFix. The PermissionsFix is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.PermissionsFix] = 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._fix_resource_permissions_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PermissionsFix, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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.PermissionsFix].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PermissionsFix]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_patch.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_patch.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py deleted file mode 100644 index 776d4d703da3..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py +++ /dev/null @@ -1,194 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._target_types_operations import build_get_request, build_list_request -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TargetTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`target_types` 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") - self._config: ChaosManagementClientConfiguration = 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, location: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.TargetType"]: - """Get a list of Target Type resources for given location. - - :param location: The name of the Azure region. Required. - :type location: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either TargetType or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.TargetType] - :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.TargetTypeListResult] = 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_list_request( - location=location, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TargetTypeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location: str, target_type_name: str, **kwargs: Any) -> _models.TargetType: - """Get a Target Type resources for given location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :return: TargetType or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.TargetType - :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.TargetType] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - target_type_name=target_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TargetType", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py deleted file mode 100644 index 09b10d0c28f4..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py +++ /dev/null @@ -1,464 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._targets_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) -from .._configuration import ChaosManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TargetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s - :attr:`targets` 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") - self._config: ChaosManagementClientConfiguration = 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_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Target"]: - """Get a list of Target resources that extend a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Target or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.Target] - :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.TargetListResult] = 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_list_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TargetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - **kwargs: Any - ) -> _models.Target: - """Get a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :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.Target] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Target", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: _models.Target, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Target - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: Union[_models.Target, IO[bytes]], - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Is either a Target type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Target or IO[bytes] - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :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 {}) - - 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.Target] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Target") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Target", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - **kwargs: Any - ) -> None: - """Delete a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py index 89eac2d5644c..f46a02655d1b 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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,13 +13,18 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore + Action, + ActionDependency, + ActionProperties, ActionStatus, + ActionSupportedTargetType, + ActionVersion, BranchStatus, Capability, - CapabilityListResult, + CapabilityProperties, CapabilityType, - CapabilityTypeListResult, + CapabilityTypeProperties, CapabilityTypePropertiesRuntimeProperties, ChaosExperimentAction, ChaosExperimentBranch, @@ -30,9 +35,15 @@ ChaosTargetSelector, ChaosTargetSimpleFilter, ChaosTargetSimpleFilterParameters, + ConfigurationExclusions, + ConfigurationFilters, ContinuousAction, + CustomerDataStorageProperties, DelayAction, + DiscoveredResource, + DiscoveredResourceProperties, DiscreteAction, + EntraIdentity, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, @@ -43,50 +54,112 @@ ExperimentExecutionDetails, ExperimentExecutionDetailsProperties, ExperimentExecutionDetailsPropertiesRunInformation, - ExperimentExecutionListResult, - ExperimentListResult, + ExperimentExecutionProperties, + ExperimentProperties, ExperimentUpdate, + ExternalResource, + FixResourcePermissionsRequest, KeyValuePair, ManagedServiceIdentity, Operation, OperationDisplay, - OperationListResult, + OperationError, OperationStatusResult, + PermissionError, + PermissionsFix, + PermissionsFixProperties, + PermissionsFixSummary, + PhysicalToLogicalZoneMapping, + PrivateAccess, + PrivateAccessPatch, + PrivateAccessProperties, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkResourceProperties, + PrivateLinkServiceConnectionState, ProxyResource, + Recommendation, Resource, + ResourceStateError, + RoleAssignmentError, + RoleAssignmentResult, + RunAfter, + Scenario, + ScenarioAction, + ScenarioConfiguration, + ScenarioConfigurationProperties, + ScenarioErrors, + ScenarioEvaluationResultItem, + ScenarioParameter, + ScenarioProperties, + ScenarioRun, + ScenarioRunProperties, + ScenarioRunResource, + ScenarioRunSummaryAction, StepStatus, SystemData, Target, - TargetListResult, TargetReference, TargetType, - TargetTypeListResult, + TargetTypeProperties, TrackedResource, UserAssignedIdentity, + Validation, + ValidationProperties, + Workspace, + WorkspaceEvaluation, + WorkspaceEvaluationProperties, + WorkspaceProperties, + WorkspaceUpdate, + ZoneResolutionInfo, + ZoneResolutionMapping, ) -from ._chaos_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore + ActionDependencyType, + ActionKind, + ActionLifecycle, ActionType, CreatedByType, ExperimentActionType, FilterType, ManagedServiceIdentityType, Origin, + ParameterType, + PermissionsFixState, + PrivateEndpointServiceConnectionStatus, ProvisioningState, + PublicNetworkAccessOption, + RecommendationStatus, + RoleAssignmentStatus, + RunAfterBehavior, + ScenarioRunState, + ScenarioSummaryState, + ScenarioValidationState, SelectorType, TargetReferenceType, + WorkspaceEvaluationStatus, + ZoneResolutionMode, ) from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Action", + "ActionDependency", + "ActionProperties", "ActionStatus", + "ActionSupportedTargetType", + "ActionVersion", "BranchStatus", "Capability", - "CapabilityListResult", + "CapabilityProperties", "CapabilityType", - "CapabilityTypeListResult", + "CapabilityTypeProperties", "CapabilityTypePropertiesRuntimeProperties", "ChaosExperimentAction", "ChaosExperimentBranch", @@ -97,9 +170,15 @@ "ChaosTargetSelector", "ChaosTargetSimpleFilter", "ChaosTargetSimpleFilterParameters", + "ConfigurationExclusions", + "ConfigurationFilters", "ContinuousAction", + "CustomerDataStorageProperties", "DelayAction", + "DiscoveredResource", + "DiscoveredResourceProperties", "DiscreteAction", + "EntraIdentity", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", @@ -110,35 +189,92 @@ "ExperimentExecutionDetails", "ExperimentExecutionDetailsProperties", "ExperimentExecutionDetailsPropertiesRunInformation", - "ExperimentExecutionListResult", - "ExperimentListResult", + "ExperimentExecutionProperties", + "ExperimentProperties", "ExperimentUpdate", + "ExternalResource", + "FixResourcePermissionsRequest", "KeyValuePair", "ManagedServiceIdentity", "Operation", "OperationDisplay", - "OperationListResult", + "OperationError", "OperationStatusResult", + "PermissionError", + "PermissionsFix", + "PermissionsFixProperties", + "PermissionsFixSummary", + "PhysicalToLogicalZoneMapping", + "PrivateAccess", + "PrivateAccessPatch", + "PrivateAccessProperties", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", + "PrivateLinkServiceConnectionState", "ProxyResource", + "Recommendation", "Resource", + "ResourceStateError", + "RoleAssignmentError", + "RoleAssignmentResult", + "RunAfter", + "Scenario", + "ScenarioAction", + "ScenarioConfiguration", + "ScenarioConfigurationProperties", + "ScenarioErrors", + "ScenarioEvaluationResultItem", + "ScenarioParameter", + "ScenarioProperties", + "ScenarioRun", + "ScenarioRunProperties", + "ScenarioRunResource", + "ScenarioRunSummaryAction", "StepStatus", "SystemData", "Target", - "TargetListResult", "TargetReference", "TargetType", - "TargetTypeListResult", + "TargetTypeProperties", "TrackedResource", "UserAssignedIdentity", + "Validation", + "ValidationProperties", + "Workspace", + "WorkspaceEvaluation", + "WorkspaceEvaluationProperties", + "WorkspaceProperties", + "WorkspaceUpdate", + "ZoneResolutionInfo", + "ZoneResolutionMapping", + "ActionDependencyType", + "ActionKind", + "ActionLifecycle", "ActionType", "CreatedByType", "ExperimentActionType", "FilterType", "ManagedServiceIdentityType", "Origin", + "ParameterType", + "PermissionsFixState", + "PrivateEndpointServiceConnectionStatus", "ProvisioningState", + "PublicNetworkAccessOption", + "RecommendationStatus", + "RoleAssignmentStatus", + "RunAfterBehavior", + "ScenarioRunState", + "ScenarioSummaryState", + "ScenarioValidationState", "SelectorType", "TargetReferenceType", + "WorkspaceEvaluationStatus", + "ZoneResolutionMode", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py deleted file mode 100644 index 9cadb7858b23..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" - - INTERNAL = "Internal" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class ExperimentActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum union of Chaos experiment action types.""" - - DELAY = "delay" - DISCRETE = "discrete" - CONTINUOUS = "continuous" - - -class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum that discriminates between filter types. Currently only ``Simple`` type is supported.""" - - SIMPLE = "Simple" - """Simple filter type.""" - - -class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity (where both SystemAssigned and UserAssigned types are - allowed). - """ - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" - - -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" - SYSTEM = "system" - USER_SYSTEM = "user,system" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Current provisioning state for a given Azure Chaos resource.""" - - SUCCEEDED = "Succeeded" - """Resource has been created.""" - FAILED = "Failed" - """Resource creation failed.""" - CANCELED = "Canceled" - """Resource creation was canceled.""" - CREATING = "Creating" - """Initial creation in progress.""" - UPDATING = "Updating" - """Update in progress.""" - DELETING = "Deleting" - """Deletion in progress.""" - - -class SelectorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum of the selector type.""" - - LIST = "List" - """List selector type.""" - QUERY = "Query" - """Query selector type.""" - - -class TargetReferenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum of the Target reference type.""" - - CHAOS_TARGET = "ChaosTarget" - """Chaos target reference type.""" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_enums.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_enums.py new file mode 100644 index 000000000000..de6d3728856c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_enums.py @@ -0,0 +1,349 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum for action dependency type.""" + + ACTION = "Action" + """Action dependency type.""" + + +class ActionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Union of action types.""" + + DISCRETE = "Discrete" + """Discrete action type.""" + CONTINUOUS = "Continuous" + """Continuous action type.""" + CANCELABLE = "Cancelable" + """Cancelable action type.""" + + +class ActionLifecycle(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum for action lifecycle states.""" + + ANY_TERMINAL = "AnyTerminal" + """Trigger when action reaches any terminal state.""" + START = "Start" + """Trigger when action starts.""" + RUNNING = "Running" + """Trigger when action is running.""" + SUCCESS = "Success" + """Trigger on success.""" + FAILURE = "Failure" + """Trigger on failure.""" + SKIPPED = "Skipped" + """Trigger when action is skipped.""" + + +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 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 ExperimentActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum union of Chaos experiment action types.""" + + DELAY = "delay" + """DELAY.""" + DISCRETE = "discrete" + """DISCRETE.""" + CONTINUOUS = "continuous" + """CONTINUOUS.""" + + +class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum that discriminates between filter types. Currently only ``Simple`` type is supported.""" + + SIMPLE = "Simple" + """Simple filter type.""" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + """No managed identity.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """System assigned managed identity.""" + USER_ASSIGNED = "UserAssigned" + """User assigned managed identity.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + """System and user assigned managed identity.""" + + +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 ParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum for parameter types.""" + + STRING = "string" + """String parameter type.""" + NUMBER = "number" + """Number parameter type.""" + BOOLEAN = "boolean" + """Boolean parameter type.""" + OBJECT = "object" + """Object parameter type.""" + ARRAY = "array" + """Array parameter type.""" + + +class PermissionsFixState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the permission fix state.""" + + NOT_STARTED = "NotStarted" + """The permission fix has not started.""" + IN_PROGRESS = "InProgress" + """The permission fix is in progress.""" + SUCCEEDED = "Succeeded" + """All role assignments succeeded.""" + FAILED = "Failed" + """All role assignments failed.""" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + """Some role assignments succeeded and some failed.""" + WHAT_IF_COMPLETED = "WhatIfCompleted" + """What-if analysis completed (no changes made).""" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + """Pending status.""" + APPROVED = "Approved" + """Approved status.""" + REJECTED = "Rejected" + """Rejected status.""" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current provisioning state for a given Azure Chaos resource.""" + + SUCCEEDED = "Succeeded" + """Resource has been created.""" + FAILED = "Failed" + """Resource creation failed.""" + CANCELED = "Canceled" + """Resource creation was canceled.""" + CREATING = "Creating" + """Initial creation in progress.""" + UPDATING = "Updating" + """Update in progress.""" + DELETING = "Deleting" + """Deletion in progress.""" + RUNNING = "Running" + """Action is running.""" + + +class PublicNetworkAccessOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Public Network Access Control for PrivateAccess resource.""" + + ENABLED = "Enabled" + """Enabled access.""" + DISABLED = "Disabled" + """Disabled access.""" + + +class RecommendationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the scenario validation state.""" + + NOT_EVALUATED = "NotEvaluated" + """The scenario recommendation status has not been evaluated.""" + RECOMMENDED = "Recommended" + """The scenario recommendation status is recommended.""" + NOT_APPLICABLE = "NotApplicable" + """The scenario recommendation status is not applicable.""" + EVALUATING = "Evaluating" + """The scenario recommendation status is currently being evaluated.""" + EVALUATION_FAILED = "EvaluationFailed" + """The scenario recommendation evaluation has failed.""" + EVALUATION_CANCELLED = "EvaluationCancelled" + """The scenario recommendation evaluation was cancelled.""" + + +class RoleAssignmentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the role assignment status.""" + + SUCCEEDED = "Succeeded" + """The role assignment succeeded.""" + FAILED = "Failed" + """The role assignment failed.""" + SKIPPED = "Skipped" + """The role assignment was skipped (already exists).""" + PENDING = "Pending" + """The role assignment is pending (what-if mode).""" + + +class RunAfterBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum for run after behavior.""" + + ANY = "Any" + """Always continues after all dependencies (like a finally block).""" + ALL = "All" + """All dependencies must be satisfied to continue.""" + AT_LEAST_ONE = "AtLeastOne" + """At least one dependency must be satisfied to continue.""" + + +class ScenarioRunState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the scenario run state.""" + + QUEUED = "Queued" + """The scenario run has been queued and is waiting to start.""" + RESOLVING = "Resolving" + """The scenario run is in the process of being resolved.""" + GENERATING = "Generating" + """The scenario run is in the process of being generated.""" + VALIDATING = "Validating" + """The scenario run is in the process of being validated.""" + VALIDATION_SUCCEEDED = "ValidationSucceeded" + """The scenario run validation has completed successfully.""" + STARTING = "Starting" + """The scenario run is in the process of being started.""" + PREPARING = "Preparing" + """The scenario run is in the process of being prepared.""" + RUNNING = "Running" + """The scenario run is in the process of running.""" + CLEANING_UP = "CleaningUp" + """The scenario run is in the process of being cleaned up.""" + CANCELING = "Canceling" + """The scenario run is in the process of being canceled.""" + CANCELED = "Canceled" + """The scenario run has been canceled.""" + SUCCEEDED = "Succeeded" + """The scenario run has completed successfully.""" + FAILED = "Failed" + """The scenario run has failed.""" + + +class ScenarioSummaryState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the scenario run summary action state.""" + + PENDING = "Pending" + """The action is pending and has not started.""" + STARTING = "Starting" + """The action is in the process of starting.""" + RUNNING = "Running" + """The action is in the process of running.""" + STOPPING = "Stopping" + """The action is in the process of stopping.""" + SUCCEEDED = "Succeeded" + """The action has completed successfully.""" + CANCELING = "Canceling" + """The action is in the process of being canceled.""" + CANCELED = "Canceled" + """The action has been canceled.""" + FAILING_ON_ERROR = "FailingOnError" + """The action is failing due to an error.""" + FAILED = "Failed" + """The action has failed.""" + SKIPPED = "Skipped" + """The action was skipped.""" + + +class ScenarioValidationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the scenario validation state.""" + + RESOLVING = "Resolving" + """The scenario validation is in a resolving state.""" + GENERATING = "Generating" + """The scenario validation is in a generating state.""" + VALIDATING = "Validating" + """The scenario validation is in a validating state.""" + ACCEPTED = "Accepted" + """The scenario validation has been accepted.""" + NOT_STARTED = "NotStarted" + """The scenario validation has not yet started.""" + REQUIRES_ATTENTION = "RequiresAttention" + """The scenario validation reflects a state that requires attention. This is a terminal failure + state indicating validation issues were found.""" + NO_RESOLVED_RESOURCES = "NoResolvedResources" + """The scenario validation found no valid resources to perform fault behaviors against. This is a + terminal failure state.""" + SUCCEEDED = "Succeeded" + """The scenario validation completed successfully and the scenario is ready to execute.""" + + +class SelectorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the selector type.""" + + LIST = "List" + """List selector type.""" + QUERY = "Query" + """Query selector type.""" + + +class TargetReferenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the Target reference type.""" + + CHAOS_TARGET = "ChaosTarget" + """Chaos target reference type.""" + + +class WorkspaceEvaluationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the workspace evaluation status.""" + + PENDING = "Pending" + """The evaluation is pending and has not started.""" + QUEUED = "Queued" + """The evaluation has been accepted and is queued for execution.""" + IN_PROGRESS = "InProgress" + """The evaluation is in progress.""" + SUCCEEDED = "Succeeded" + """The evaluation completed successfully.""" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + """The evaluation partially succeeded — some scenarios succeeded while others failed.""" + FAILED = "Failed" + """The evaluation failed.""" + CANCELED = "Canceled" + """The evaluation was canceled.""" + + +class ZoneResolutionMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The zone resolution mode for a scenario run.""" + + LOGICAL = "logical" + """Logical zone mode — customer specified logical zone identifiers directly.""" + PHYSICAL = "physical" + """Physical zone mode — system resolved physical zones to per-subscription logical zones at + execution time.""" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py new file mode 100644 index 000000000000..2a0e551a465e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py @@ -0,0 +1,4089 @@ +# 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, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import ExperimentActionType, FilterType, SelectorType + +if TYPE_CHECKING: + from .. import models as _models + + +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.chaos.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 ProxyResource(Resource): + """Proxy 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.chaos.models.SystemData + """ + + +class Action(ProxyResource): + """Model that represents an Action 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.chaos.models.SystemData + :ivar properties: The properties of the action resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.ActionProperties + """ + + properties: "_models.ActionProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the action resource. Required.""" + + __flattened_items = [ + "canonical_id", + "display_name", + "description", + "action_name", + "version", + "action_type", + "supported_target_types", + "parameters_schema", + "recommended_roles", + ] + + @overload + def __init__( + self, + *, + properties: "_models.ActionProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ActionDependency(_Model): + """Model that represents an action dependency. + + :ivar type: The type of dependency. Required. "Action" + :vartype type: str or ~azure.mgmt.chaos.models.ActionDependencyType + :ivar name: Name of the action this depends on. Required. + :vartype name: str + :ivar on_action_lifecycle: The lifecycle state of the dependency action that triggers this + action to start. Known values are: "AnyTerminal", "Start", "Running", "Success", "Failure", and + "Skipped". + :vartype on_action_lifecycle: str or ~azure.mgmt.chaos.models.ActionLifecycle + """ + + type: Union[str, "_models.ActionDependencyType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of dependency. Required. \"Action\"""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the action this depends on. Required.""" + on_action_lifecycle: Optional[Union[str, "_models.ActionLifecycle"]] = rest_field( + name="onActionLifecycle", visibility=["read", "create", "update", "delete", "query"] + ) + """The lifecycle state of the dependency action that triggers this action to start. Known values + are: \"AnyTerminal\", \"Start\", \"Running\", \"Success\", \"Failure\", and \"Skipped\".""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ActionDependencyType"], + name: str, + on_action_lifecycle: Optional[Union[str, "_models.ActionLifecycle"]] = 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 ActionProperties(_Model): + """Model that represents the properties of an Action resource. + + :ivar canonical_id: Canonical identifier of the action (e.g., + "microsoft-compute-shutdown/1.0"). + :vartype canonical_id: str + :ivar display_name: Human-readable display name of the action. + :vartype display_name: str + :ivar description: Description of what this action does. + :vartype description: str + :ivar action_name: The short name of the action (e.g., "Shutdown"). + :vartype action_name: str + :ivar version: The version of the action (e.g., "1.0.0"). + :vartype version: str + :ivar action_type: The type of the action. Known values are: "Discrete", "Continuous", and + "Cancelable". + :vartype action_type: str or ~azure.mgmt.chaos.models.ActionKind + :ivar supported_target_types: List of target types supported by this action. + :vartype supported_target_types: list[~azure.mgmt.chaos.models.ActionSupportedTargetType] + :ivar parameters_schema: JSON Schema describing the parameters for this action. + :vartype parameters_schema: any + :ivar recommended_roles: Recommended Azure RBAC role definition GUIDs for this action. + :vartype recommended_roles: list[str] + """ + + canonical_id: Optional[str] = rest_field(name="canonicalId", visibility=["read"]) + """Canonical identifier of the action (e.g., \"microsoft-compute-shutdown/1.0\").""" + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """Human-readable display name of the action.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of what this action does.""" + action_name: Optional[str] = rest_field(name="actionName", visibility=["read"]) + """The short name of the action (e.g., \"Shutdown\").""" + version: Optional[str] = rest_field(visibility=["read"]) + """The version of the action (e.g., \"1.0.0\").""" + action_type: Optional[Union[str, "_models.ActionKind"]] = rest_field(name="actionType", visibility=["read"]) + """The type of the action. Known values are: \"Discrete\", \"Continuous\", and \"Cancelable\".""" + supported_target_types: Optional[list["_models.ActionSupportedTargetType"]] = rest_field( + name="supportedTargetTypes", visibility=["read"] + ) + """List of target types supported by this action.""" + parameters_schema: Optional[Any] = rest_field(name="parametersSchema", visibility=["read"]) + """JSON Schema describing the parameters for this action.""" + recommended_roles: Optional[list[str]] = rest_field(name="recommendedRoles", visibility=["read"]) + """Recommended Azure RBAC role definition GUIDs for this action.""" + + +class ActionStatus(_Model): + """Model that represents the an action and its status. + + :ivar action_name: The name of the action status. + :vartype action_name: str + :ivar action_id: The id of the action status. + :vartype action_id: str + :ivar status: The status of the action. + :vartype status: str + :ivar start_time: String that represents the start time of the action. + :vartype start_time: ~datetime.datetime + :ivar end_time: String that represents the end time of the action. + :vartype end_time: ~datetime.datetime + :ivar targets: The array of targets. + :vartype targets: + list[~azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsProperties] + """ + + action_name: Optional[str] = rest_field(name="actionName", visibility=["read"]) + """The name of the action status.""" + action_id: Optional[str] = rest_field(name="actionId", visibility=["read"]) + """The id of the action status.""" + status: Optional[str] = rest_field(visibility=["read"]) + """The status of the action.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """String that represents the start time of the action.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """String that represents the end time of the action.""" + targets: Optional[list["_models.ExperimentExecutionActionTargetDetailsProperties"]] = rest_field( + visibility=["read"] + ) + """The array of targets.""" + + +class ActionSupportedTargetType(_Model): + """Model that represents a target type supported by an action. + + :ivar target_type: The Azure resource type (e.g., "Microsoft.Compute/virtualMachines"). + :vartype target_type: str + :ivar required_permissions: List of Azure permissions required for this target type. + :vartype required_permissions: list[str] + """ + + target_type: Optional[str] = rest_field( + name="targetType", visibility=["read", "create", "update", "delete", "query"] + ) + """The Azure resource type (e.g., \"Microsoft.Compute/virtualMachines\").""" + required_permissions: Optional[list[str]] = rest_field( + name="requiredPermissions", visibility=["read", "create", "update", "delete", "query"] + ) + """List of Azure permissions required for this target type.""" + + @overload + def __init__( + self, + *, + target_type: Optional[str] = None, + required_permissions: 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 ActionVersion(ProxyResource): + """Model that represents an Action Version 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.chaos.models.SystemData + :ivar properties: The properties of the action version resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.ActionProperties + """ + + properties: "_models.ActionProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the action version resource. Required.""" + + __flattened_items = [ + "canonical_id", + "display_name", + "description", + "action_name", + "version", + "action_type", + "supported_target_types", + "parameters_schema", + "recommended_roles", + ] + + @overload + def __init__( + self, + *, + properties: "_models.ActionProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BranchStatus(_Model): + """Model that represents the a list of actions and action statuses. + + :ivar branch_name: The name of the branch status. + :vartype branch_name: str + :ivar branch_id: The id of the branch status. + :vartype branch_id: str + :ivar status: The status of the branch. + :vartype status: str + :ivar actions: The array of actions. + :vartype actions: list[~azure.mgmt.chaos.models.ActionStatus] + """ + + branch_name: Optional[str] = rest_field(name="branchName", visibility=["read"]) + """The name of the branch status.""" + branch_id: Optional[str] = rest_field(name="branchId", visibility=["read"]) + """The id of the branch status.""" + status: Optional[str] = rest_field(visibility=["read"]) + """The status of the branch.""" + actions: Optional[list["_models.ActionStatus"]] = rest_field(visibility=["read"]) + """The array of actions.""" + + +class Capability(ProxyResource): + """Model that represents a Capability 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.chaos.models.SystemData + :ivar properties: The properties of a capability resource. + :vartype properties: ~azure.mgmt.chaos.models.CapabilityProperties + """ + + properties: Optional["_models.CapabilityProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of a capability resource.""" + + __flattened_items = ["publisher", "target_type", "description", "parameters_schema", "urn", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CapabilityProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CapabilityProperties(_Model): + """Model that represents the Capability properties model. + + :ivar publisher: String of the Publisher that this Capability extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability extends. + :vartype target_type: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + :ivar provisioning_state: Resource provisioning state. Not currently in use because resource is + created synchronously. Known values are: "Succeeded", "Failed", "Canceled", "Creating", + "Updating", "Deleting", and "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + """ + + publisher: Optional[str] = rest_field(visibility=["read"]) + """String of the Publisher that this Capability extends.""" + target_type: Optional[str] = rest_field(name="targetType", visibility=["read"]) + """String of the Target Type that this Capability extends.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Localized string of the description.""" + parameters_schema: Optional[str] = rest_field(name="parametersSchema", visibility=["read"]) + """URL to retrieve JSON schema of the Capability parameters.""" + urn: Optional[str] = rest_field(visibility=["read"]) + """String of the URN for this Capability Type.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Resource provisioning state. Not currently in use because resource is created synchronously. + Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", + \"Deleting\", and \"Running\".""" + + +class CapabilityType(ProxyResource): + """Model that represents a Capability Type 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.chaos.models.SystemData + :ivar properties: The properties of the capability type resource. + :vartype properties: ~azure.mgmt.chaos.models.CapabilityTypeProperties + """ + + properties: Optional["_models.CapabilityTypeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the capability type resource.""" + + __flattened_items = [ + "publisher", + "target_type", + "display_name", + "description", + "parameters_schema", + "urn", + "kind", + "azure_rbac_actions", + "azure_rbac_data_actions", + "required_azure_role_definition_ids", + "runtime_properties", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CapabilityTypeProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CapabilityTypeProperties(_Model): + """Model that represents the Capability Type properties model. + + :ivar publisher: String of the Publisher that this Capability Type extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability Type extends. + :vartype target_type: str + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability Type parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + :ivar kind: String of the kind of this Capability Type. + :vartype kind: str + :ivar azure_rbac_actions: Control plane actions necessary to execute capability type. + :vartype azure_rbac_actions: list[str] + :ivar azure_rbac_data_actions: Data plane actions necessary to execute capability type. + :vartype azure_rbac_data_actions: list[str] + :ivar required_azure_role_definition_ids: Required Azure Role Definition Ids to execute + capability type. + :vartype required_azure_role_definition_ids: list[str] + :ivar runtime_properties: Runtime properties of this Capability Type. + :vartype runtime_properties: ~azure.mgmt.chaos.models.CapabilityTypePropertiesRuntimeProperties + """ + + publisher: Optional[str] = rest_field(visibility=["read"]) + """String of the Publisher that this Capability Type extends.""" + target_type: Optional[str] = rest_field(name="targetType", visibility=["read"]) + """String of the Target Type that this Capability Type extends.""" + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """Localized string of the display name.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Localized string of the description.""" + parameters_schema: Optional[str] = rest_field(name="parametersSchema", visibility=["read"]) + """URL to retrieve JSON schema of the Capability Type parameters.""" + urn: Optional[str] = rest_field(visibility=["read"]) + """String of the URN for this Capability Type.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """String of the kind of this Capability Type.""" + azure_rbac_actions: Optional[list[str]] = rest_field(name="azureRbacActions", visibility=["read"]) + """Control plane actions necessary to execute capability type.""" + azure_rbac_data_actions: Optional[list[str]] = rest_field(name="azureRbacDataActions", visibility=["read"]) + """Data plane actions necessary to execute capability type.""" + required_azure_role_definition_ids: Optional[list[str]] = rest_field( + name="requiredAzureRoleDefinitionIds", visibility=["read"] + ) + """Required Azure Role Definition Ids to execute capability type.""" + runtime_properties: Optional["_models.CapabilityTypePropertiesRuntimeProperties"] = rest_field( + name="runtimeProperties", visibility=["read"] + ) + """Runtime properties of this Capability Type.""" + + +class CapabilityTypePropertiesRuntimeProperties(_Model): # pylint: disable=name-too-long + """Runtime properties of this Capability Type. + + :ivar kind: String of the kind of the resource's action type (continuous or discrete). + :vartype kind: str + """ + + kind: Optional[str] = rest_field(visibility=["read"]) + """String of the kind of the resource's action type (continuous or discrete).""" + + +class ChaosExperimentAction(_Model): + """Model that represents the base action model. 9 total per experiment. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContinuousAction, DelayAction, DiscreteAction + + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar type: Chaos experiment action discriminator type. Required. Known values are: "delay", + "discrete", and "continuous". + :vartype type: str or ~azure.mgmt.chaos.models.ExperimentActionType + """ + + __mapping__: dict[str, _Model] = {} + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String that represents a Capability URN. Required.""" + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Chaos experiment action discriminator type. Required. Known values are: \"delay\", + \"discrete\", and \"continuous\".""" + + @overload + def __init__( + self, + *, + name: str, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ChaosExperimentBranch(_Model): + """Model that represents a branch in the step. 9 total per experiment. + + :ivar name: String of the branch name. Required. + :vartype name: str + :ivar actions: List of actions. Required. + :vartype actions: list[~azure.mgmt.chaos.models.ChaosExperimentAction] + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String of the branch name. Required.""" + actions: list["_models.ChaosExperimentAction"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of actions. Required.""" + + @overload + def __init__( + self, + *, + name: str, + actions: list["_models.ChaosExperimentAction"], + ) -> 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 ChaosExperimentStep(_Model): + """Model that represents a step in the Experiment resource. + + :ivar name: String of the step name. Required. + :vartype name: str + :ivar branches: List of branches. Required. + :vartype branches: list[~azure.mgmt.chaos.models.ChaosExperimentBranch] + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String of the step name. Required.""" + branches: list["_models.ChaosExperimentBranch"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of branches. Required.""" + + @overload + def __init__( + self, + *, + name: str, + branches: list["_models.ChaosExperimentBranch"], + ) -> 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 ChaosTargetFilter(_Model): + """Model that represents available filter types that can be applied to a targets list. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ChaosTargetSimpleFilter + + :ivar type: Chaos target filter discriminator type. Required. "Simple" + :vartype type: str or ~azure.mgmt.chaos.models.FilterType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Chaos target filter discriminator type. Required. \"Simple\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ChaosTargetSelector(_Model): + """Model that represents a selector in the Experiment resource. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ChaosTargetListSelector, ChaosTargetQuerySelector + + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar type: Chaos target selector discriminator type. Required. Known values are: "List" and + "Query". + :vartype type: str or ~azure.mgmt.chaos.models.SelectorType + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + """ + + __mapping__: dict[str, _Model] = {} + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String of the selector ID. Required.""" + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Chaos target selector discriminator type. Required. Known values are: \"List\" and \"Query\".""" + filter: Optional["_models.ChaosTargetFilter"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Model that represents available filter types that can be applied to a targets list.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + type: str, + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + ) -> 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 ChaosTargetListSelector(ChaosTargetSelector, discriminator="List"): + """Model that represents a list selector. + + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :ivar targets: List of Target references. Required. + :vartype targets: list[~azure.mgmt.chaos.models.TargetReference] + :ivar type: Enum of the selector type. Required. List selector type. + :vartype type: str or ~azure.mgmt.chaos.models.LIST + """ + + targets: list["_models.TargetReference"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of Target references. Required.""" + type: Literal[SelectorType.LIST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum of the selector type. Required. List selector type.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + targets: list["_models.TargetReference"], + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + ) -> 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) + self.type = SelectorType.LIST # type: ignore + + +class ChaosTargetQuerySelector(ChaosTargetSelector, discriminator="Query"): + """Model that represents a query selector. + + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :ivar query_string: Azure Resource Graph (ARG) Query Language query for target resources. + Required. + :vartype query_string: str + :ivar subscription_ids: Subscription id list to scope resource query. Required. + :vartype subscription_ids: list[str] + :ivar type: Enum of the selector type. Required. Query selector type. + :vartype type: str or ~azure.mgmt.chaos.models.QUERY + """ + + query_string: str = rest_field(name="queryString", visibility=["read", "create", "update", "delete", "query"]) + """Azure Resource Graph (ARG) Query Language query for target resources. Required.""" + subscription_ids: list[str] = rest_field( + name="subscriptionIds", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription id list to scope resource query. Required.""" + type: Literal[SelectorType.QUERY] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum of the selector type. Required. Query selector type.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + query_string: str, + subscription_ids: list[str], + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + ) -> 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) + self.type = SelectorType.QUERY # type: ignore + + +class ChaosTargetSimpleFilter(ChaosTargetFilter, discriminator="Simple"): + """Model that represents a simple target filter. + + :ivar parameters: Model that represents the Simple filter parameters. + :vartype parameters: ~azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters + :ivar type: Enum that discriminates between filter types. Currently only ``Simple`` type is + supported. Required. Simple filter type. + :vartype type: str or ~azure.mgmt.chaos.models.SIMPLE + """ + + parameters: Optional["_models.ChaosTargetSimpleFilterParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Model that represents the Simple filter parameters.""" + type: Literal[FilterType.SIMPLE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum that discriminates between filter types. Currently only ``Simple`` type is supported. + Required. Simple filter type.""" + + @overload + def __init__( + self, + *, + parameters: Optional["_models.ChaosTargetSimpleFilterParameters"] = 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) + self.type = FilterType.SIMPLE # type: ignore + + +class ChaosTargetSimpleFilterParameters(_Model): + """Model that represents the Simple filter parameters. + + :ivar zones: List of Azure availability zones to filter targets by. + :vartype zones: list[str] + """ + + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of Azure availability zones to filter targets by.""" + + @overload + def __init__( + self, + *, + 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) + + +class ConfigurationExclusions(_Model): + """Model that represents exclusion criteria for protecting resources from fault injection. Uses + union (OR) logic - a resource is excluded if it matches ANY criteria. + + :ivar resources: Array of specific resource IDs to exclude from fault injection. + :vartype resources: list[str] + :ivar tags: Array of tag key-value pairs. Resources with matching tags are excluded. + :vartype tags: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar types: Array of resource types. All resources of these types are excluded. + :vartype types: list[str] + """ + + resources: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of specific resource IDs to exclude from fault injection.""" + tags: Optional[list["_models.KeyValuePair"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of tag key-value pairs. Resources with matching tags are excluded.""" + types: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of resource types. All resources of these types are excluded.""" + + @overload + def __init__( + self, + *, + resources: Optional[list[str]] = None, + tags: Optional[list["_models.KeyValuePair"]] = None, + types: 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 ConfigurationFilters(_Model): + """Model that represents filter criteria for constraining which discovered + resources participate in fault injection. + + Uses intersection (AND) logic — a resource is included only if it matches all criteria. + + :ivar locations: Array of Azure location strings. Only resources in these locations are + included. + + Null or omitted means all locations (no filter). Empty array means include nothing. + :vartype locations: list[str] + :ivar zones: Array of availability zone identifiers ("1", "2", "3", "zone-redundant"). + Only resources whose zones intersect this list are included. + + Null or omitted means all zones (including non-zonal). Empty array means include nothing. + + Mutually exclusive with ``physicalZones`` — set one or the other, not both. + :vartype zones: list[str] + :ivar physical_zones: Array of physical availability zone identifiers in ``{region}-az{N}`` + format + (e.g., ``"westus2-az1"``). Only resources in the corresponding logical zone + for each subscription are included. + + At execution time, each physical zone is resolved to per-subscription + logical zones via the Azure locations API. The resolved mapping is surfaced + on the scenario run response (``zoneResolution``). + + Null or omitted means physical zone targeting is not used. + Only one physical zone is supported in preview. + + Mutually exclusive with ``zones`` — set one or the other, not both. + :vartype physical_zones: list[str] + """ + + locations: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of Azure location strings. Only resources in these locations are included. + + Null or omitted means all locations (no filter). Empty array means include nothing.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of availability zone identifiers (\"1\", \"2\", \"3\", \"zone-redundant\"). + Only resources whose zones intersect this list are included. + + Null or omitted means all zones (including non-zonal). Empty array means include nothing. + + Mutually exclusive with ``physicalZones`` — set one or the other, not both.""" + physical_zones: Optional[list[str]] = rest_field( + name="physicalZones", visibility=["read", "create", "update", "delete", "query"] + ) + """Array of physical availability zone identifiers in ``{region}-az{N}`` format + (e.g., ``\"westus2-az1\"``). Only resources in the corresponding logical zone + for each subscription are included. + + At execution time, each physical zone is resolved to per-subscription + logical zones via the Azure locations API. The resolved mapping is surfaced + on the scenario run response (``zoneResolution``). + + Null or omitted means physical zone targeting is not used. + Only one physical zone is supported in preview. + + Mutually exclusive with ``zones`` — set one or the other, not both.""" + + @overload + def __init__( + self, + *, + locations: Optional[list[str]] = None, + zones: Optional[list[str]] = None, + physical_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) + + +class ContinuousAction(ChaosExperimentAction, discriminator="continuous"): + """Model that represents a continuous action. + + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar duration: ISO8601 formatted string that represents a duration. Required. + :vartype duration: ~datetime.timedelta + :ivar parameters: List of key value pairs. Required. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar selector_id: String that represents a selector. Required. + :vartype selector_id: str + :ivar type: Enum that discriminates between action models. Required. CONTINUOUS. + :vartype type: str or ~azure.mgmt.chaos.models.CONTINUOUS + """ + + duration: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ISO8601 formatted string that represents a duration. Required.""" + parameters: list["_models.KeyValuePair"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of key value pairs. Required.""" + selector_id: str = rest_field(name="selectorId", visibility=["read", "create", "update", "delete", "query"]) + """String that represents a selector. Required.""" + type: Literal[ExperimentActionType.CONTINUOUS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum that discriminates between action models. Required. CONTINUOUS.""" + + @overload + def __init__( + self, + *, + name: str, + duration: datetime.timedelta, + parameters: list["_models.KeyValuePair"], + selector_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ExperimentActionType.CONTINUOUS # type: ignore + + +class CustomerDataStorageProperties(_Model): + """Model that represents the Customer Managed Storage for an Experiment. + + :ivar storage_account_resource_id: Azure Resource ID of the Storage account to use for Customer + Data storage. + :vartype storage_account_resource_id: str + :ivar blob_container_name: Name of the Azure Blob Storage container to use or create. + :vartype blob_container_name: str + """ + + storage_account_resource_id: Optional[str] = rest_field( + name="storageAccountResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Resource ID of the Storage account to use for Customer Data storage.""" + blob_container_name: Optional[str] = rest_field( + name="blobContainerName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the Azure Blob Storage container to use or create.""" + + @overload + def __init__( + self, + *, + storage_account_resource_id: Optional[str] = None, + blob_container_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 DelayAction(ChaosExperimentAction, discriminator="delay"): + """Model that represents a delay action. + + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar duration: ISO8601 formatted string that represents a duration. Required. + :vartype duration: ~datetime.timedelta + :ivar type: Enum that discriminates between action models. Required. DELAY. + :vartype type: str or ~azure.mgmt.chaos.models.DELAY + """ + + duration: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ISO8601 formatted string that represents a duration. Required.""" + type: Literal[ExperimentActionType.DELAY] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum that discriminates between action models. Required. DELAY.""" + + @overload + def __init__( + self, + *, + name: str, + duration: datetime.timedelta, + ) -> 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) + self.type = ExperimentActionType.DELAY # type: ignore + + +class DiscoveredResource(ProxyResource): + """Model that represents a discovered 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.chaos.models.SystemData + :ivar properties: The properties of the discovered resource. + :vartype properties: ~azure.mgmt.chaos.models.DiscoveredResourceProperties + """ + + properties: Optional["_models.DiscoveredResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the discovered resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.DiscoveredResourceProperties"] = 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 DiscoveredResourceProperties(_Model): + """Model that represents the properties of a discovered resource. + + :ivar resource_namespace: The namespace of the discovered resource. Required. + :vartype resource_namespace: str + :ivar resource_name: The name of the discovered resource. Required. + :vartype resource_name: str + :ivar resource_type: The resource type of the discovered resource. Required. + :vartype resource_type: str + :ivar fully_qualified_identifier: The fully qualified identifier of the discovered resource. + Required. + :vartype fully_qualified_identifier: str + :ivar discovered_at: The date and time when the resource was discovered. Required. + :vartype discovered_at: ~datetime.datetime + :ivar scope: The scope of the discovered resource. Required. + :vartype scope: str + """ + + resource_namespace: str = rest_field(name="namespace", visibility=["read"]) + """The namespace of the discovered resource. Required.""" + resource_name: str = rest_field(name="resourceName", visibility=["read"]) + """The name of the discovered resource. Required.""" + resource_type: str = rest_field(name="resourceType", visibility=["read"]) + """The resource type of the discovered resource. Required.""" + fully_qualified_identifier: str = rest_field(name="fullyQualifiedIdentifier", visibility=["read"]) + """The fully qualified identifier of the discovered resource. Required.""" + discovered_at: datetime.datetime = rest_field(name="discoveredAt", visibility=["read"], format="rfc3339") + """The date and time when the resource was discovered. Required.""" + scope: str = rest_field(visibility=["read"]) + """The scope of the discovered resource. Required.""" + + +class DiscreteAction(ChaosExperimentAction, discriminator="discrete"): + """Model that represents a discrete action. + + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar parameters: List of key value pairs. Required. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar selector_id: String that represents a selector. Required. + :vartype selector_id: str + :ivar type: Enum that discriminates between action models. Required. DISCRETE. + :vartype type: str or ~azure.mgmt.chaos.models.DISCRETE + """ + + parameters: list["_models.KeyValuePair"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of key value pairs. Required.""" + selector_id: str = rest_field(name="selectorId", visibility=["read", "create", "update", "delete", "query"]) + """String that represents a selector. Required.""" + type: Literal[ExperimentActionType.DISCRETE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Enum that discriminates between action models. Required. DISCRETE.""" + + @overload + def __init__( + self, + *, + name: str, + parameters: list["_models.KeyValuePair"], + selector_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = ExperimentActionType.DISCRETE # type: ignore + + +class EntraIdentity(_Model): + """Model that represents the Azure Entra identity. + + :ivar object_id: The identity object id. Required. + :vartype object_id: str + :ivar tenant_id: The identity tenant id. Required. + :vartype tenant_id: str + """ + + object_id: str = rest_field(name="objectId", visibility=["read"]) + """The identity object id. Required.""" + tenant_id: str = rest_field(name="tenantId", visibility=["read"]) + """The identity tenant id. Required.""" + + +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.chaos.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.chaos.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.chaos.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class 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.chaos.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 Experiment(TrackedResource): + """Model that represents a Experiment 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.chaos.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 identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity + :ivar properties: The properties of the experiment resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.ExperimentProperties + """ + + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + properties: "_models.ExperimentProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the experiment resource. Required.""" + + __flattened_items = ["provisioning_state", "steps", "selectors", "customer_data_storage"] + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.ExperimentProperties", + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ExperimentExecution(ProxyResource): + """Model that represents the execution of a Experiment. + + :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.chaos.models.SystemData + :ivar properties: The properties of experiment execution status. + :vartype properties: ~azure.mgmt.chaos.models.ExperimentExecutionProperties + """ + + properties: Optional["_models.ExperimentExecutionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of experiment execution status.""" + + __flattened_items = ["status", "started_at", "stopped_at", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ExperimentExecutionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ExperimentExecutionActionTargetDetailsError(_Model): # pylint: disable=name-too-long + """Model that represents the Experiment action target details error model. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + + +class ExperimentExecutionActionTargetDetailsProperties(_Model): # pylint: disable=name-too-long + """Model that represents the Experiment action target details properties model. + + :ivar status: The status of the execution. + :vartype status: str + :ivar target: The target for the action. + :vartype target: str + :ivar target_failed_time: String that represents the failed date time. + :vartype target_failed_time: ~datetime.datetime + :ivar target_completed_time: String that represents the completed date time. + :vartype target_completed_time: ~datetime.datetime + :ivar error: The error of the action. + :vartype error: ~azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsError + """ + + status: Optional[str] = rest_field(visibility=["read"]) + """The status of the execution.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The target for the action.""" + target_failed_time: Optional[datetime.datetime] = rest_field( + name="targetFailedTime", visibility=["read"], format="rfc3339" + ) + """String that represents the failed date time.""" + target_completed_time: Optional[datetime.datetime] = rest_field( + name="targetCompletedTime", visibility=["read"], format="rfc3339" + ) + """String that represents the completed date time.""" + error: Optional["_models.ExperimentExecutionActionTargetDetailsError"] = rest_field(visibility=["read"]) + """The error of the action.""" + + +class ExperimentExecutionDetails(_Model): + """Model that represents the execution details of an Experiment. + + :ivar type: String of the resource type. + :vartype type: str + :ivar id: String of the fully qualified resource ID. + :vartype id: str + :ivar name: String of the resource name. + :vartype name: str + :ivar properties: The properties of the experiment execution details. + :vartype properties: ~azure.mgmt.chaos.models.ExperimentExecutionDetailsProperties + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """String of the resource type.""" + id: Optional[str] = rest_field(visibility=["read"]) + """String of the fully qualified resource ID.""" + name: Optional[str] = rest_field(visibility=["read"]) + """String of the resource name.""" + properties: Optional["_models.ExperimentExecutionDetailsProperties"] = rest_field(visibility=["read"]) + """The properties of the experiment execution details.""" + + __flattened_items = [ + "status", + "started_at", + "stopped_at", + "provisioning_state", + "failure_reason", + "last_action_at", + "run_information", + ] + + +class ExperimentExecutionDetailsProperties(_Model): + """Model that represents the extended properties of an experiment execution. + + :ivar status: The status of the execution. + :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime + :ivar provisioning_state: Resource provisioning state. Not currently in use for executions. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar failure_reason: The reason why the execution failed. + :vartype failure_reason: str + :ivar last_action_at: String that represents the last action date time. + :vartype last_action_at: ~datetime.datetime + :ivar run_information: The information of the experiment run. + :vartype run_information: + ~azure.mgmt.chaos.models.ExperimentExecutionDetailsPropertiesRunInformation + """ + + status: Optional[str] = rest_field(visibility=["read"]) + """The status of the execution.""" + started_at: Optional[datetime.datetime] = rest_field(name="startedAt", visibility=["read"], format="rfc3339") + """String that represents the start date time.""" + stopped_at: Optional[datetime.datetime] = rest_field(name="stoppedAt", visibility=["read"], format="rfc3339") + """String that represents the stop date time.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Resource provisioning state. Not currently in use for executions. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + failure_reason: Optional[str] = rest_field(name="failureReason", visibility=["read"]) + """The reason why the execution failed.""" + last_action_at: Optional[datetime.datetime] = rest_field(name="lastActionAt", visibility=["read"], format="rfc3339") + """String that represents the last action date time.""" + run_information: Optional["_models.ExperimentExecutionDetailsPropertiesRunInformation"] = rest_field( + name="runInformation", visibility=["read"] + ) + """The information of the experiment run.""" + + +class ExperimentExecutionDetailsPropertiesRunInformation(_Model): # pylint: disable=name-too-long + """The information of the experiment run. + + :ivar steps: The steps of the experiment run. + :vartype steps: list[~azure.mgmt.chaos.models.StepStatus] + """ + + steps: Optional[list["_models.StepStatus"]] = rest_field(visibility=["read"]) + """The steps of the experiment run.""" + + +class ExperimentExecutionProperties(_Model): + """Model that represents the execution properties of an Experiment. + + :ivar status: The status of the execution. + :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime + :ivar provisioning_state: Resource provisioning state. Not currently in use for executions. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + """ + + status: Optional[str] = rest_field(visibility=["read"]) + """The status of the execution.""" + started_at: Optional[datetime.datetime] = rest_field(name="startedAt", visibility=["read"], format="rfc3339") + """String that represents the start date time.""" + stopped_at: Optional[datetime.datetime] = rest_field(name="stoppedAt", visibility=["read"], format="rfc3339") + """String that represents the stop date time.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Resource provisioning state. Not currently in use for executions. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + + +class ExperimentProperties(_Model): + """Model that represents the Experiment properties model. + + :ivar provisioning_state: Most recent provisioning state for the given experiment resource. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar steps: List of steps. Required. + :vartype steps: list[~azure.mgmt.chaos.models.ChaosExperimentStep] + :ivar selectors: List of selectors. Required. + :vartype selectors: list[~azure.mgmt.chaos.models.ChaosTargetSelector] + :ivar customer_data_storage: Optional customer-managed Storage account where Experiment schema + will be stored. + :vartype customer_data_storage: ~azure.mgmt.chaos.models.CustomerDataStorageProperties + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Most recent provisioning state for the given experiment resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + steps: list["_models.ChaosExperimentStep"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of steps. Required.""" + selectors: list["_models.ChaosTargetSelector"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of selectors. Required.""" + customer_data_storage: Optional["_models.CustomerDataStorageProperties"] = rest_field( + name="customerDataStorage", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional customer-managed Storage account where Experiment schema will be stored.""" + + @overload + def __init__( + self, + *, + steps: list["_models.ChaosExperimentStep"], + selectors: list["_models.ChaosTargetSelector"], + customer_data_storage: Optional["_models.CustomerDataStorageProperties"] = 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 ExperimentUpdate(_Model): + """Describes an experiment update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = 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 ExternalResource(_Model): + """Model that represents an external resource reference. + + :ivar resource_id: The resource ID of the external resource. + :vartype resource_id: str + """ + + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ID of the external resource.""" + + @overload + def __init__( + self, + *, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FixResourcePermissionsRequest(_Model): + """Request body for fixing resource permissions. + + :ivar what_if: Optional value that indicates whether to run a "dry run" of fixing resource + permissions. + :vartype what_if: bool + """ + + what_if: Optional[bool] = rest_field(name="whatIf", visibility=["read", "create", "update", "delete", "query"]) + """Optional value that indicates whether to run a \"dry run\" of fixing resource permissions.""" + + @overload + def __init__( + self, + *, + what_if: 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 KeyValuePair(_Model): + """A map used to describe parameters for actions or configurations. + + :ivar key: The name of the setting for the action. Required. + :vartype key: str + :ivar value: The value of the setting for the action. Required. + :vartype value: str + """ + + key: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the setting for the action. Required.""" + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value of the setting for the action. Required.""" + + @overload + def __init__( + self, + *, + key: str, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServiceIdentity(_Model): + """Managed service identity (system assigned and/or user assigned identities). + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: The type of managed identity assigned to this resource. Required. Known values are: + "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.chaos.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The identities assigned to this resource by the user. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.chaos.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The service principal ID of the system assigned identity. This property will only be provided + for a system assigned identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of the system assigned identity. This property will only be provided for a system + assigned identity.""" + type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of managed identity assigned to this resource. Required. Known values are: \"None\", + \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The identities assigned to this resource by the user.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API Operation. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for Azure Resource Manager/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.chaos.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.chaos.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.chaos.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 OperationError(_Model): + """Represents a system or infrastructure error encountered during an async operation. + + :ivar error_code: The error code identifying the type of system error. Required. + :vartype error_code: str + :ivar error_message: A human-readable description of the system error. Required. + :vartype error_message: str + """ + + error_code: str = rest_field(name="errorCode", visibility=["read", "create", "update", "delete", "query"]) + """The error code identifying the type of system error. Required.""" + error_message: str = rest_field(name="errorMessage", visibility=["read", "create", "update", "delete", "query"]) + """A human-readable description of the system error. Required.""" + + @overload + def __init__( + self, + *, + error_code: str, + error_message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationStatusResult(_Model): + """The current status of an async operation. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.chaos.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.chaos.models.ErrorDetail + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified ID for the async operation.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the async operation.""" + status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation status. Required.""" + percent_complete: Optional[float] = rest_field( + name="percentComplete", visibility=["read", "create", "update", "delete", "query"] + ) + """Percent of the operation that is complete.""" + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time of the operation.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The end time of the operation.""" + operations: Optional[list["_models.OperationStatusResult"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The operations list.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If present, details of the operation error.""" + resource_id: Optional[str] = rest_field(name="resourceId", visibility=["read"]) + """Fully qualified ID of the resource against which the original async operation was started.""" + + @overload + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[list["_models.OperationStatusResult"]] = 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 PermissionError(_Model): + """Model that represents the permission error. + + :ivar resource_id: The resource id for the affected resource. Required. + :vartype resource_id: str + :ivar missing_permissions: The missing permissions. Required. + :vartype missing_permissions: list[str] + :ivar required_permissions: The required permissions. Required. + :vartype required_permissions: list[str] + :ivar recommended_roles: The recommended roles. Required. + :vartype recommended_roles: list[str] + :ivar identity: The identity. + :vartype identity: ~azure.mgmt.chaos.models.EntraIdentity + """ + + resource_id: str = rest_field(name="resourceId", visibility=["read"]) + """The resource id for the affected resource. Required.""" + missing_permissions: list[str] = rest_field(name="missingPermissions", visibility=["read"]) + """The missing permissions. Required.""" + required_permissions: list[str] = rest_field(name="requiredPermissions", visibility=["read"]) + """The required permissions. Required.""" + recommended_roles: list[str] = rest_field(name="recommendedRoles", visibility=["read"]) + """The recommended roles. Required.""" + identity: Optional["_models.EntraIdentity"] = rest_field(visibility=["read"]) + """The identity.""" + + +class PermissionsFix(ProxyResource): + """Model that represents the fix resource permissions result. + + :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.chaos.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.chaos.models.PermissionsFixProperties + """ + + properties: Optional["_models.PermissionsFixProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.PermissionsFixProperties"] = 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 PermissionsFixProperties(_Model): + """Model that represents the properties of the permission fix operation. + + :ivar state: The permission fix state. Required. Known values are: "NotStarted", "InProgress", + "Succeeded", "Failed", "PartiallySucceeded", and "WhatIfCompleted". + :vartype state: str or ~azure.mgmt.chaos.models.PermissionsFixState + :ivar started_at: The permission fix UTC start time. Required. + :vartype started_at: ~datetime.datetime + :ivar completed_at: The permission fix UTC end time. + :vartype completed_at: ~datetime.datetime + :ivar what_if_mode: Whether this was a what-if (dry run) operation. Required. + :vartype what_if_mode: bool + :ivar role_assignments: The list of role assignment results. Required. + :vartype role_assignments: list[~azure.mgmt.chaos.models.RoleAssignmentResult] + :ivar summary: Summary of the permission fix operation. Required. + :vartype summary: ~azure.mgmt.chaos.models.PermissionsFixSummary + """ + + state: Union[str, "_models.PermissionsFixState"] = rest_field(visibility=["read"]) + """The permission fix state. Required. Known values are: \"NotStarted\", \"InProgress\", + \"Succeeded\", \"Failed\", \"PartiallySucceeded\", and \"WhatIfCompleted\".""" + started_at: datetime.datetime = rest_field(name="startedAt", visibility=["read"], format="rfc3339") + """The permission fix UTC start time. Required.""" + completed_at: Optional[datetime.datetime] = rest_field(name="completedAt", visibility=["read"], format="rfc3339") + """The permission fix UTC end time.""" + what_if_mode: bool = rest_field(name="whatIfMode", visibility=["read"]) + """Whether this was a what-if (dry run) operation. Required.""" + role_assignments: list["_models.RoleAssignmentResult"] = rest_field(name="roleAssignments", visibility=["read"]) + """The list of role assignment results. Required.""" + summary: "_models.PermissionsFixSummary" = rest_field(visibility=["read"]) + """Summary of the permission fix operation. Required.""" + + +class PermissionsFixSummary(_Model): + """Summary of the permission fix operation. + + :ivar total_required: Total number of role assignments required. Required. + :vartype total_required: int + :ivar succeeded: Number of successful role assignments. Required. + :vartype succeeded: int + :ivar failed: Number of failed role assignments. Required. + :vartype failed: int + :ivar skipped: Number of skipped role assignments (already existed). Required. + :vartype skipped: int + """ + + total_required: int = rest_field(name="totalRequired", visibility=["read"]) + """Total number of role assignments required. Required.""" + succeeded: int = rest_field(visibility=["read"]) + """Number of successful role assignments. Required.""" + failed: int = rest_field(visibility=["read"]) + """Number of failed role assignments. Required.""" + skipped: int = rest_field(visibility=["read"]) + """Number of skipped role assignments (already existed). Required.""" + + +class PhysicalToLogicalZoneMapping(_Model): + """Maps a physical zone to the resolved logical zone for a given subscription. + + :ivar physical_zone: The physical availability zone (e.g., ``"westus2-az1"``). Required. + :vartype physical_zone: str + :ivar logical_zone: The logical availability zone resolved for this subscription (e.g., + ``"1"``, ``"2"``, ``"3"``). Required. + :vartype logical_zone: str + """ + + physical_zone: str = rest_field(name="physicalZone", visibility=["read"]) + """The physical availability zone (e.g., ``\"westus2-az1\"``). Required.""" + logical_zone: str = rest_field(name="logicalZone", visibility=["read"]) + """The logical availability zone resolved for this subscription (e.g., ``\"1\"``, ``\"2\"``, + ``\"3\"``). Required.""" + + +class PrivateAccess(TrackedResource): + """PrivateAccesses 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.chaos.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-specific properties for this resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.PrivateAccessProperties + """ + + properties: "_models.PrivateAccessProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource. Required.""" + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.PrivateAccessProperties", + 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 PrivateAccessPatch(_Model): + """Describes a private access update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateAccessProperties(_Model): + """The properties of a private access resource. + + :ivar provisioning_state: Most recent provisioning state for the given privateAccess resource. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar private_endpoint_connections: A readonly collection of private endpoint connection. + Currently only one endpoint connection is supported. + :vartype private_endpoint_connections: list[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :ivar public_network_access: Public Network Access Control for PrivateAccess resource. Known + values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.chaos.models.PublicNetworkAccessOption + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Most recent provisioning state for the given privateAccess resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """A readonly collection of private endpoint connection. Currently only one endpoint connection is + supported.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessOption"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Public Network Access Control for PrivateAccess resource. Known values are: \"Enabled\" and + \"Disabled\".""" + + @overload + def __init__( + self, + *, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessOption"]] = 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 PrivateEndpoint(_Model): + """The private endpoint resource. + + :ivar id: The Azure identifier for private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The Azure identifier for private endpoint.""" + + +class PrivateEndpointConnection(ProxyResource): + """The private endpoint connection 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.chaos.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.chaos.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = 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 PrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection. + + :ivar group_ids: The group ids for the private endpoint resource. + :vartype group_ids: list[str] + :ivar private_endpoint: The private endpoint resource. + :vartype private_endpoint: ~azure.mgmt.chaos.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.chaos.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + """ + + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """The group ids for the private endpoint resource.""" + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The private endpoint resource.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the private endpoint connection resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = 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 PrivateLinkResource(TrackedResource): + """A private link 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.chaos.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-specific properties for this resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.PrivateLinkResourceProperties + """ + + properties: "_models.PrivateLinkResourceProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource. Required.""" + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.PrivateLinkResourceProperties", + 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 PrivateLinkResourceListResult(_Model): + """A list of private link resources. + + :ivar value: The PrivateLinkResource items on this page. Required. + :vartype value: list[~azure.mgmt.chaos.models.PrivateLinkResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.PrivateLinkResource"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The PrivateLinkResource 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.PrivateLinkResource"], + 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 PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource private link DNS zone name. + :vartype required_zone_names: list[str] + :ivar provisioning_state: Resource provisioning state. Not currently in use. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource private link DNS zone name.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Resource provisioning state. Not currently in use. Known values are: \"Succeeded\", \"Failed\", + \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and \"Running\".""" + + @overload + def __init__( + self, + *, + required_zone_names: 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 PrivateLinkServiceConnectionState(_Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or ~azure.mgmt.chaos.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: 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 Recommendation(_Model): + """Model that represents a scenario recommendation. + + :ivar recommendation_status: The recommendation status. Required. Known values are: + "NotEvaluated", "Recommended", "NotApplicable", "Evaluating", "EvaluationFailed", and + "EvaluationCancelled". + :vartype recommendation_status: str or ~azure.mgmt.chaos.models.RecommendationStatus + :ivar evaluation_run_at: The UTC time when the recommendation was evaluated. + :vartype evaluation_run_at: ~datetime.datetime + """ + + recommendation_status: Union[str, "_models.RecommendationStatus"] = rest_field( + name="recommendationStatus", visibility=["read"] + ) + """The recommendation status. Required. Known values are: \"NotEvaluated\", \"Recommended\", + \"NotApplicable\", \"Evaluating\", \"EvaluationFailed\", and \"EvaluationCancelled\".""" + evaluation_run_at: Optional[datetime.datetime] = rest_field( + name="evaluationRunAt", visibility=["read"], format="rfc3339" + ) + """The UTC time when the recommendation was evaluated.""" + + +class ResourceStateError(_Model): + """Model that represents the resource state error. + + :ivar resource_id: The resource id for the affected resource. Required. + :vartype resource_id: str + :ivar error_code: The error code. Required. + :vartype error_code: int + :ivar error_message: The error message. Required. + :vartype error_message: str + :ivar remediation_uri: The remediation uri. Required. + :vartype remediation_uri: str + """ + + resource_id: str = rest_field(name="resourceId", visibility=["read"]) + """The resource id for the affected resource. Required.""" + error_code: int = rest_field(name="errorCode", visibility=["read"]) + """The error code. Required.""" + error_message: str = rest_field(name="errorMessage", visibility=["read"]) + """The error message. Required.""" + remediation_uri: str = rest_field(name="remediationUri", visibility=["read"]) + """The remediation uri. Required.""" + + +class RoleAssignmentError(_Model): + """Error details for a failed role assignment. + + :ivar code: Azure error code. Required. + :vartype code: str + :ivar message: Error message. Required. + :vartype message: str + """ + + code: str = rest_field(visibility=["read"]) + """Azure error code. Required.""" + message: str = rest_field(visibility=["read"]) + """Error message. Required.""" + + +class RoleAssignmentResult(_Model): + """Result of a single role assignment operation. + + :ivar target_resource_id: The target Azure resource ID. Required. + :vartype target_resource_id: str + :ivar principal_id: The managed identity principal ID. Required. + :vartype principal_id: str + :ivar role_definition_id: The Azure RBAC role definition ID. Required. + :vartype role_definition_id: str + :ivar role_definition_name: Human-readable role name. Required. + :vartype role_definition_name: str + :ivar scope: The scope at which the role was/will be assigned. Required. + :vartype scope: str + :ivar status: The status of the role assignment operation. Required. Known values are: + "Succeeded", "Failed", "Skipped", and "Pending". + :vartype status: str or ~azure.mgmt.chaos.models.RoleAssignmentStatus + :ivar role_assignment_id: The created role assignment resource ID (null if failed or what-if + mode). + :vartype role_assignment_id: str + :ivar error: Error details if the assignment failed. + :vartype error: ~azure.mgmt.chaos.models.RoleAssignmentError + """ + + target_resource_id: str = rest_field(name="targetResourceId", visibility=["read"]) + """The target Azure resource ID. Required.""" + principal_id: str = rest_field(name="principalId", visibility=["read"]) + """The managed identity principal ID. Required.""" + role_definition_id: str = rest_field(name="roleDefinitionId", visibility=["read"]) + """The Azure RBAC role definition ID. Required.""" + role_definition_name: str = rest_field(name="roleDefinitionName", visibility=["read"]) + """Human-readable role name. Required.""" + scope: str = rest_field(visibility=["read"]) + """The scope at which the role was/will be assigned. Required.""" + status: Union[str, "_models.RoleAssignmentStatus"] = rest_field(visibility=["read"]) + """The status of the role assignment operation. Required. Known values are: \"Succeeded\", + \"Failed\", \"Skipped\", and \"Pending\".""" + role_assignment_id: Optional[str] = rest_field(name="roleAssignmentId", visibility=["read"]) + """The created role assignment resource ID (null if failed or what-if mode).""" + error: Optional["_models.RoleAssignmentError"] = rest_field(visibility=["read"]) + """Error details if the assignment failed.""" + + +class RunAfter(_Model): + """Model that represents action dependencies. + + :ivar behavior: Defines how multiple dependencies are evaluated. Known values are: "Any", + "All", and "AtLeastOne". + :vartype behavior: str or ~azure.mgmt.chaos.models.RunAfterBehavior + :ivar items_property: Array of action dependencies. Required. + :vartype items_property: list[~azure.mgmt.chaos.models.ActionDependency] + """ + + behavior: Optional[Union[str, "_models.RunAfterBehavior"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines how multiple dependencies are evaluated. Known values are: \"Any\", \"All\", and + \"AtLeastOne\".""" + items_property: list["_models.ActionDependency"] = rest_field( + name="items", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="items" + ) + """Array of action dependencies. Required.""" + + @overload + def __init__( + self, + *, + items_property: list["_models.ActionDependency"], + behavior: Optional[Union[str, "_models.RunAfterBehavior"]] = 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 Scenario(ProxyResource): + """Model that represents the scenario. + + :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.chaos.models.SystemData + :ivar properties: The properties of scenario. + :vartype properties: ~azure.mgmt.chaos.models.ScenarioProperties + """ + + properties: Optional["_models.ScenarioProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of scenario.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ScenarioProperties"] = 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 ScenarioAction(_Model): + """Model that represents a scenario action. + + :ivar name: Unique name for the action. Required. + :vartype name: str + :ivar action_id: Identifier of the action and version (e.g., "microsoft-compute-shutdown/1.0"). + Required. + :vartype action_id: str + :ivar description: Human-readable description of what this action does. + :vartype description: str + :ivar duration: ISO 8601 duration for how long the action runs (e.g., PT30M for 30 minutes). + Supports template macro syntax (%%\\{parameters.\\\\}%%). Required. + :vartype duration: str + :ivar parameters: Action-specific parameter values. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar run_after: Action dependencies that control when this action starts. + :vartype run_after: ~azure.mgmt.chaos.models.RunAfter + :ivar wait_before: ISO 8601 duration to wait before action starts (e.g., PT30S for 30 seconds). + Supports template macro syntax. + :vartype wait_before: str + :ivar timeout: ISO 8601 duration for maximum action execution time. Supports template macro + syntax. + :vartype timeout: str + :ivar external_resource: External resource reference for the action. + :vartype external_resource: ~azure.mgmt.chaos.models.ExternalResource + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Unique name for the action. Required.""" + action_id: str = rest_field(name="actionId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the action and version (e.g., \"microsoft-compute-shutdown/1.0\"). Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Human-readable description of what this action does.""" + duration: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ISO 8601 duration for how long the action runs (e.g., PT30M for 30 minutes). Supports template + macro syntax (%%\{parameters.\\}%%). Required.""" + parameters: Optional[list["_models.KeyValuePair"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Action-specific parameter values.""" + run_after: Optional["_models.RunAfter"] = rest_field( + name="runAfter", visibility=["read", "create", "update", "delete", "query"] + ) + """Action dependencies that control when this action starts.""" + wait_before: Optional[str] = rest_field( + name="waitBefore", visibility=["read", "create", "update", "delete", "query"] + ) + """ISO 8601 duration to wait before action starts (e.g., PT30S for 30 seconds). Supports template + macro syntax.""" + timeout: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ISO 8601 duration for maximum action execution time. Supports template macro syntax.""" + external_resource: Optional["_models.ExternalResource"] = rest_field( + name="externalResource", visibility=["read", "create", "update", "delete", "query"] + ) + """External resource reference for the action.""" + + @overload + def __init__( + self, + *, + name: str, + action_id: str, + duration: str, + description: Optional[str] = None, + parameters: Optional[list["_models.KeyValuePair"]] = None, + run_after: Optional["_models.RunAfter"] = None, + wait_before: Optional[str] = None, + timeout: Optional[str] = None, + external_resource: Optional["_models.ExternalResource"] = 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 ScenarioConfiguration(ProxyResource): + """Model that represents the scenario. + + :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.chaos.models.SystemData + :ivar properties: The properties of scenario definition. + :vartype properties: ~azure.mgmt.chaos.models.ScenarioConfigurationProperties + """ + + properties: Optional["_models.ScenarioConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of scenario definition.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ScenarioConfigurationProperties"] = 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 ScenarioConfigurationProperties(_Model): + """Model that represents the properties of the scenario configuration. + + :ivar scenario_id: Resource ID of the scenario this configuration applies to. Required. + :vartype scenario_id: str + :ivar parameters: Runtime parameter values for the scenario. Keys must match parameter names + defined in the scenario. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar exclusions: Exclusion criteria for protecting resources from fault injection. + :vartype exclusions: ~azure.mgmt.chaos.models.ConfigurationExclusions + :ivar provisioning_state: Most recent provisioning state for the given scenario resource. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar filters: Filter criteria used to constrain which discovered resources participate in + fault injection. + :vartype filters: ~azure.mgmt.chaos.models.ConfigurationFilters + """ + + scenario_id: str = rest_field(name="scenarioId", visibility=["read", "create", "update", "delete", "query"]) + """Resource ID of the scenario this configuration applies to. Required.""" + parameters: Optional[list["_models.KeyValuePair"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Runtime parameter values for the scenario. Keys must match parameter names defined in the + scenario.""" + exclusions: Optional["_models.ConfigurationExclusions"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Exclusion criteria for protecting resources from fault injection.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Most recent provisioning state for the given scenario resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + filters: Optional["_models.ConfigurationFilters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Filter criteria used to constrain which discovered resources participate in fault injection.""" + + @overload + def __init__( + self, + *, + scenario_id: str, + parameters: Optional[list["_models.KeyValuePair"]] = None, + exclusions: Optional["_models.ConfigurationExclusions"] = None, + filters: Optional["_models.ConfigurationFilters"] = 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 ScenarioErrors(_Model): + """Model that represents the scenario run errors. + + :ivar error_code: Error code for internal server errors. + :vartype error_code: str + :ivar error_message: Error message for internal server errors. + :vartype error_message: str + :ivar permission: Any permission errors associated with the scenario run. Required. + :vartype permission: list[~azure.mgmt.chaos.models.PermissionError] + :ivar resource: Any resource state errors associated with the scenario run. Required. + :vartype resource: list[~azure.mgmt.chaos.models.ResourceStateError] + """ + + error_code: Optional[str] = rest_field(name="errorCode", visibility=["read", "create", "update", "delete", "query"]) + """Error code for internal server errors.""" + error_message: Optional[str] = rest_field( + name="errorMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """Error message for internal server errors.""" + permission: list["_models.PermissionError"] = rest_field(visibility=["read"]) + """Any permission errors associated with the scenario run. Required.""" + resource: list["_models.ResourceStateError"] = rest_field(visibility=["read"]) + """Any resource state errors associated with the scenario run. Required.""" + + @overload + def __init__( + self, + *, + error_code: Optional[str] = None, + error_message: 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 ScenarioEvaluationResultItem(_Model): + """Model that represents a single scenario evaluation result. + + :ivar scenario_name: The name of the scenario that was evaluated. Required. + :vartype scenario_name: str + :ivar evaluation_result: The evaluation result for this scenario. Required. Known values are: + "NotEvaluated", "Recommended", "NotApplicable", "Evaluating", "EvaluationFailed", and + "EvaluationCancelled". + :vartype evaluation_result: str or ~azure.mgmt.chaos.models.RecommendationStatus + """ + + scenario_name: str = rest_field(name="scenarioName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the scenario that was evaluated. Required.""" + evaluation_result: Union[str, "_models.RecommendationStatus"] = rest_field( + name="evaluationResult", visibility=["read", "create", "update", "delete", "query"] + ) + """The evaluation result for this scenario. Required. Known values are: \"NotEvaluated\", + \"Recommended\", \"NotApplicable\", \"Evaluating\", \"EvaluationFailed\", and + \"EvaluationCancelled\".""" + + @overload + def __init__( + self, + *, + scenario_name: str, + evaluation_result: Union[str, "_models.RecommendationStatus"], + ) -> 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 ScenarioParameter(_Model): + """Model that represents a single scenario parameter definition. + + :ivar name: The name of the parameter. Required. + :vartype name: str + :ivar type: Parameter data type. Required. Known values are: "string", "number", "boolean", + "object", and "array". + :vartype type: str or ~azure.mgmt.chaos.models.ParameterType + :ivar default: Default value for the parameter. + :vartype default: str + :ivar required: Whether this parameter is required. + :vartype required: bool + :ivar description: Description of the parameter. + :vartype description: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the parameter. Required.""" + type: Union[str, "_models.ParameterType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Parameter data type. Required. Known values are: \"string\", \"number\", \"boolean\", + \"object\", and \"array\".""" + default: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Default value for the parameter.""" + required: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether this parameter is required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the parameter.""" + + @overload + def __init__( + self, + *, + name: str, + type: Union[str, "_models.ParameterType"], + default: Optional[str] = None, + required: Optional[bool] = None, + description: 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 ScenarioProperties(_Model): + """Model that represents the properties of the scenario. + + :ivar provisioning_state: Most recent provisioning state for the given scenario resource. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar created_from: Resource ID of the template version this scenario was created from + (optional). + :vartype created_from: str + :ivar version: Version of the scenario. + :vartype version: str + :ivar description: Description of what this scenario does (optional). + :vartype description: str + :ivar parameters: Parameter definitions for the scenario. Required. + :vartype parameters: list[~azure.mgmt.chaos.models.ScenarioParameter] + :ivar actions: Array of actions that define the scenario's orchestration. Required. + :vartype actions: list[~azure.mgmt.chaos.models.ScenarioAction] + :ivar recommendation: The recommendation information for this scenario. + :vartype recommendation: ~azure.mgmt.chaos.models.Recommendation + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Most recent provisioning state for the given scenario resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + created_from: Optional[str] = rest_field(name="createdFrom", visibility=["read"]) + """Resource ID of the template version this scenario was created from (optional).""" + version: Optional[str] = rest_field(visibility=["read"]) + """Version of the scenario.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of what this scenario does (optional).""" + parameters: list["_models.ScenarioParameter"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Parameter definitions for the scenario. Required.""" + actions: list["_models.ScenarioAction"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of actions that define the scenario's orchestration. Required.""" + recommendation: Optional["_models.Recommendation"] = rest_field(visibility=["read"]) + """The recommendation information for this scenario.""" + + @overload + def __init__( + self, + *, + parameters: list["_models.ScenarioParameter"], + actions: list["_models.ScenarioAction"], + description: 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 ScenarioRun(ProxyResource): + """Model that represents the scenario run. + + :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.chaos.models.SystemData + :ivar properties: The properties of scenario run. + :vartype properties: ~azure.mgmt.chaos.models.ScenarioRunProperties + """ + + properties: Optional["_models.ScenarioRunProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of scenario run.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ScenarioRunProperties"] = 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 ScenarioRunProperties(_Model): + """Model that represents the properties of the scenario run. + + :ivar workspace_name: The workspace name. Required. + :vartype workspace_name: str + :ivar scenario_name: The scenario name. Required. + :vartype scenario_name: str + :ivar scenario_configuration_name: The scenario configuration name. Required. + :vartype scenario_configuration_name: str + :ivar managed_identity_principal_id: The principal id for the managed identity used for the + run. Required. + :vartype managed_identity_principal_id: str + :ivar status: The scenario run status. Required. Known values are: "Queued", "Resolving", + "Generating", "Validating", "ValidationSucceeded", "Starting", "Preparing", "Running", + "CleaningUp", "Canceling", "Canceled", "Succeeded", and "Failed". + :vartype status: str or ~azure.mgmt.chaos.models.ScenarioRunState + :ivar resources: All resources discovered for the scenario run. Required. + :vartype resources: list[~azure.mgmt.chaos.models.ScenarioRunResource] + :ivar errors: System or infrastructure errors encountered during the scenario run. + :vartype errors: list[~azure.mgmt.chaos.models.OperationError] + :ivar execution_errors: Business errors from fault injection — permission and resource state + issues. + :vartype execution_errors: ~azure.mgmt.chaos.models.ScenarioErrors + :ivar scenario_run_json: The scenario run json. + :vartype scenario_run_json: str + :ivar scenario_run_summary: The scenario run summary. + :vartype scenario_run_summary: list[~azure.mgmt.chaos.models.ScenarioRunSummaryAction] + :ivar start_time: When the scenario run was started. Required. + :vartype start_time: ~datetime.datetime + :ivar end_time: When the scenario run was completed. + :vartype end_time: ~datetime.datetime + :ivar zone_resolution: Zone resolution information. Present when the scenario configuration + used physical zone targeting (``physicalZones``). Contains the mode, requested physical zones, + and per-subscription logical zone mappings. + :vartype zone_resolution: ~azure.mgmt.chaos.models.ZoneResolutionInfo + """ + + workspace_name: str = rest_field(name="workspaceName", visibility=["read"]) + """The workspace name. Required.""" + scenario_name: str = rest_field(name="scenarioName", visibility=["read"]) + """The scenario name. Required.""" + scenario_configuration_name: str = rest_field(name="scenarioConfigurationName", visibility=["read"]) + """The scenario configuration name. Required.""" + managed_identity_principal_id: str = rest_field(name="managedIdentityPrincipalId", visibility=["read"]) + """The principal id for the managed identity used for the run. Required.""" + status: Union[str, "_models.ScenarioRunState"] = rest_field(visibility=["read"]) + """The scenario run status. Required. Known values are: \"Queued\", \"Resolving\", \"Generating\", + \"Validating\", \"ValidationSucceeded\", \"Starting\", \"Preparing\", \"Running\", + \"CleaningUp\", \"Canceling\", \"Canceled\", \"Succeeded\", and \"Failed\".""" + resources: list["_models.ScenarioRunResource"] = rest_field(visibility=["read"]) + """All resources discovered for the scenario run. Required.""" + errors: Optional[list["_models.OperationError"]] = rest_field(visibility=["read"]) + """System or infrastructure errors encountered during the scenario run.""" + execution_errors: Optional["_models.ScenarioErrors"] = rest_field(name="executionErrors", visibility=["read"]) + """Business errors from fault injection — permission and resource state issues.""" + scenario_run_json: Optional[str] = rest_field(name="scenarioRunJson", visibility=["read"]) + """The scenario run json.""" + scenario_run_summary: Optional[list["_models.ScenarioRunSummaryAction"]] = rest_field( + name="scenarioRunSummary", visibility=["read"] + ) + """The scenario run summary.""" + start_time: datetime.datetime = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """When the scenario run was started. Required.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """When the scenario run was completed.""" + zone_resolution: Optional["_models.ZoneResolutionInfo"] = rest_field(name="zoneResolution", visibility=["read"]) + """Zone resolution information. Present when the scenario configuration used physical zone + targeting (``physicalZones``). Contains the mode, requested physical zones, and + per-subscription logical zone mappings.""" + + +class ScenarioRunResource(_Model): + """Model that represents the scenario run resource. + + :ivar id: The resource id. Required. + :vartype id: str + """ + + id: str = rest_field(visibility=["read"]) + """The resource id. Required.""" + + +class ScenarioRunSummaryAction(_Model): + """Model that represents the scenario run action. + + :ivar resources: The resources associated with the specified action. Required. + :vartype resources: list[~azure.mgmt.chaos.models.ScenarioRunResource] + :ivar action_urn: The urn for the given chaos action. Required. + :vartype action_urn: str + :ivar state: The state of the action. Required. Known values are: "Pending", "Starting", + "Running", "Stopping", "Succeeded", "Canceling", "Canceled", "FailingOnError", "Failed", and + "Skipped". + :vartype state: str or ~azure.mgmt.chaos.models.ScenarioSummaryState + :ivar started_at: When the action was started. + :vartype started_at: ~datetime.datetime + :ivar completed_at: When the action was completed. + :vartype completed_at: ~datetime.datetime + """ + + resources: list["_models.ScenarioRunResource"] = rest_field(visibility=["read"]) + """The resources associated with the specified action. Required.""" + action_urn: str = rest_field(name="actionUrn", visibility=["read"]) + """The urn for the given chaos action. Required.""" + state: Union[str, "_models.ScenarioSummaryState"] = rest_field(visibility=["read"]) + """The state of the action. Required. Known values are: \"Pending\", \"Starting\", \"Running\", + \"Stopping\", \"Succeeded\", \"Canceling\", \"Canceled\", \"FailingOnError\", \"Failed\", and + \"Skipped\".""" + started_at: Optional[datetime.datetime] = rest_field(name="startedAt", visibility=["read"], format="rfc3339") + """When the action was started.""" + completed_at: Optional[datetime.datetime] = rest_field(name="completedAt", visibility=["read"], format="rfc3339") + """When the action was completed.""" + + +class StepStatus(_Model): + """Model that represents the a list of branches and branch statuses. + + :ivar step_name: The name of the step. + :vartype step_name: str + :ivar step_id: The id of the step. + :vartype step_id: str + :ivar status: The value of the status of the step. + :vartype status: str + :ivar branches: The array of branches. + :vartype branches: list[~azure.mgmt.chaos.models.BranchStatus] + """ + + step_name: Optional[str] = rest_field(name="stepName", visibility=["read"]) + """The name of the step.""" + step_id: Optional[str] = rest_field(name="stepId", visibility=["read"]) + """The id of the step.""" + status: Optional[str] = rest_field(visibility=["read"]) + """The value of the status of the step.""" + branches: Optional[list["_models.BranchStatus"]] = rest_field(visibility=["read"]) + """The array of branches.""" + + +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.chaos.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.chaos.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 Target(ProxyResource): + """Model that represents a Target 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.chaos.models.SystemData + :ivar properties: The properties of the target resource. Required. + :vartype properties: dict[str, any] + :ivar location: Azure resource location. + :vartype location: str + """ + + properties: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the target resource. Required.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """Azure resource location.""" + + @overload + def __init__( + self, + *, + properties: dict[str, Any], + location: 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 TargetReference(_Model): + """Model that represents a reference to a Target in the selector. + + :ivar type: Enum of the Target reference type. Required. "ChaosTarget" + :vartype type: str or ~azure.mgmt.chaos.models.TargetReferenceType + :ivar id: String of the resource ID of a Target resource. Required. + :vartype id: str + """ + + type: Union[str, "_models.TargetReferenceType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Enum of the Target reference type. Required. \"ChaosTarget\"""" + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """String of the resource ID of a Target resource. Required.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.TargetReferenceType"], + id: str, # pylint: disable=redefined-builtin + ) -> 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 TargetType(ProxyResource): + """Model that represents a Target Type 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.chaos.models.SystemData + :ivar properties: The properties of the target type resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.TargetTypeProperties + """ + + properties: "_models.TargetTypeProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the target type resource. Required.""" + + __flattened_items = ["display_name", "description", "properties_schema", "resource_types"] + + @overload + def __init__( + self, + *, + properties: "_models.TargetTypeProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TargetTypeProperties(_Model): + """Model that represents the base Target Type properties model. + + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar properties_schema: URL to retrieve JSON schema of the Target Type properties. + :vartype properties_schema: str + :ivar resource_types: List of resource types this Target Type can extend. + :vartype resource_types: list[str] + """ + + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """Localized string of the display name.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Localized string of the description.""" + properties_schema: Optional[str] = rest_field(name="propertiesSchema", visibility=["read"]) + """URL to retrieve JSON schema of the Target Type properties.""" + resource_types: Optional[list[str]] = rest_field(name="resourceTypes", visibility=["read"]) + """List of resource types this Target Type can extend.""" + + +class UserAssignedIdentity(_Model): + """User assigned identity properties. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client ID of the assigned identity.""" + + +class Validation(ProxyResource): + """Concrete proxy resource types can be created by aliasing this type using a specific property + type. + + :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.chaos.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.chaos.models.ValidationProperties + """ + + properties: Optional["_models.ValidationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ValidationProperties"] = 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 ValidationProperties(_Model): + """Model that represents the properties of the scenario validation. + + :ivar status: The scenario validation status. Required. Known values are: "Resolving", + "Generating", "Validating", "Accepted", "NotStarted", "RequiresAttention", + "NoResolvedResources", and "Succeeded". + :vartype status: str or ~azure.mgmt.chaos.models.ScenarioValidationState + :ivar start_time: The scenario validation UTC start time. Required. + :vartype start_time: ~datetime.datetime + :ivar execution_plan_json: Execution plan created from validation. This plan will be executed + as-is on next scenario execution. + :vartype execution_plan_json: str + :ivar end_time: The scenario validation UTC end time. + :vartype end_time: ~datetime.datetime + :ivar errors: System or infrastructure errors encountered during validation. + :vartype errors: list[~azure.mgmt.chaos.models.OperationError] + :ivar validation_errors: Business errors from validation — permission and resource state + issues. + :vartype validation_errors: ~azure.mgmt.chaos.models.ScenarioErrors + """ + + status: Union[str, "_models.ScenarioValidationState"] = rest_field(visibility=["read"]) + """The scenario validation status. Required. Known values are: \"Resolving\", \"Generating\", + \"Validating\", \"Accepted\", \"NotStarted\", \"RequiresAttention\", \"NoResolvedResources\", + and \"Succeeded\".""" + start_time: datetime.datetime = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The scenario validation UTC start time. Required.""" + execution_plan_json: Optional[str] = rest_field( + name="executionPlanJson", visibility=["read", "create", "update", "delete", "query"] + ) + """Execution plan created from validation. This plan will be executed as-is on next scenario + execution.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """The scenario validation UTC end time.""" + errors: Optional[list["_models.OperationError"]] = rest_field(visibility=["read"]) + """System or infrastructure errors encountered during validation.""" + validation_errors: Optional["_models.ScenarioErrors"] = rest_field( + name="validationErrors", visibility=["read", "create", "update", "delete", "query"] + ) + """Business errors from validation — permission and resource state issues.""" + + @overload + def __init__( + self, + *, + execution_plan_json: Optional[str] = None, + validation_errors: Optional["_models.ScenarioErrors"] = 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 Workspace(TrackedResource): + """Model that represents a Workspace 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.chaos.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 identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity + :ivar properties: The properties of the Workspace resource. Required. + :vartype properties: ~azure.mgmt.chaos.models.WorkspaceProperties + """ + + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + properties: "_models.WorkspaceProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The properties of the Workspace resource. Required.""" + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.WorkspaceProperties", + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = 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 WorkspaceEvaluation(ProxyResource): + """Model that represents the latest workspace evaluation result. + + :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.chaos.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.chaos.models.WorkspaceEvaluationProperties + """ + + properties: Optional["_models.WorkspaceEvaluationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.WorkspaceEvaluationProperties"] = 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 WorkspaceEvaluationProperties(_Model): + """Model that represents the properties of the workspace evaluation. + + :ivar status: The evaluation status. Required. Known values are: "Pending", "Queued", + "InProgress", "Succeeded", "PartiallySucceeded", "Failed", and "Canceled". + :vartype status: str or ~azure.mgmt.chaos.models.WorkspaceEvaluationStatus + :ivar start_time: The evaluation UTC start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: The evaluation UTC end time. + :vartype end_time: ~datetime.datetime + :ivar errors: System or infrastructure errors encountered during evaluation. + :vartype errors: list[~azure.mgmt.chaos.models.OperationError] + :ivar workspace_id: The workspace ID this evaluation belongs to. Required. + :vartype workspace_id: str + :ivar num_scenarios_to_evaluate: The number of scenarios to evaluate. + :vartype num_scenarios_to_evaluate: int + :ivar num_scenarios_evaluated_succeeded: The number of scenarios that evaluated successfully. + :vartype num_scenarios_evaluated_succeeded: int + :ivar num_scenarios_evaluated_failed: The number of scenarios that failed evaluation. + :vartype num_scenarios_evaluated_failed: int + :ivar num_scenarios_evaluated_cancelled: The number of scenarios that were cancelled during + evaluation. + :vartype num_scenarios_evaluated_cancelled: int + :ivar evaluation_result: The overall evaluation result. Known values are: "NotEvaluated", + "Recommended", "NotApplicable", "Evaluating", "EvaluationFailed", and "EvaluationCancelled". + :vartype evaluation_result: str or ~azure.mgmt.chaos.models.RecommendationStatus + :ivar results: Per-scenario evaluation results. + :vartype results: list[~azure.mgmt.chaos.models.ScenarioEvaluationResultItem] + """ + + status: Union[str, "_models.WorkspaceEvaluationStatus"] = rest_field(visibility=["read"]) + """The evaluation status. Required. Known values are: \"Pending\", \"Queued\", \"InProgress\", + \"Succeeded\", \"PartiallySucceeded\", \"Failed\", and \"Canceled\".""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The evaluation UTC start time.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """The evaluation UTC end time.""" + errors: Optional[list["_models.OperationError"]] = rest_field(visibility=["read"]) + """System or infrastructure errors encountered during evaluation.""" + workspace_id: str = rest_field(name="workspaceId", visibility=["read"]) + """The workspace ID this evaluation belongs to. Required.""" + num_scenarios_to_evaluate: Optional[int] = rest_field(name="numScenariosToEvaluate", visibility=["read"]) + """The number of scenarios to evaluate.""" + num_scenarios_evaluated_succeeded: Optional[int] = rest_field( + name="numScenariosEvaluatedSucceeded", visibility=["read"] + ) + """The number of scenarios that evaluated successfully.""" + num_scenarios_evaluated_failed: Optional[int] = rest_field(name="numScenariosEvaluatedFailed", visibility=["read"]) + """The number of scenarios that failed evaluation.""" + num_scenarios_evaluated_cancelled: Optional[int] = rest_field( + name="numScenariosEvaluatedCancelled", visibility=["read"] + ) + """The number of scenarios that were cancelled during evaluation.""" + evaluation_result: Optional[Union[str, "_models.RecommendationStatus"]] = rest_field( + name="evaluationResult", visibility=["read"] + ) + """The overall evaluation result. Known values are: \"NotEvaluated\", \"Recommended\", + \"NotApplicable\", \"Evaluating\", \"EvaluationFailed\", and \"EvaluationCancelled\".""" + results: Optional[list["_models.ScenarioEvaluationResultItem"]] = rest_field(visibility=["read"]) + """Per-scenario evaluation results.""" + + +class WorkspaceProperties(_Model): + """Model that represents the Workspace properties model. + + :ivar provisioning_state: Most recent provisioning state for the given Workspace resource. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", "Deleting", and + "Running". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState + :ivar communication_endpoint: The communication endpoint used to connect and communicate with + the workspace for fault-injection orchestration. + :vartype communication_endpoint: str + :ivar scopes: The intended workspace-level resource scope to be used by child scenarios. + Required. + :vartype scopes: list[str] + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Most recent provisioning state for the given Workspace resource. Known values are: + \"Succeeded\", \"Failed\", \"Canceled\", \"Creating\", \"Updating\", \"Deleting\", and + \"Running\".""" + communication_endpoint: Optional[str] = rest_field(name="communicationEndpoint", visibility=["read"]) + """The communication endpoint used to connect and communicate with the workspace for + fault-injection orchestration.""" + scopes: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The intended workspace-level resource scope to be used by child scenarios. Required.""" + + @overload + def __init__( + self, + *, + scopes: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WorkspaceUpdate(_Model): + """Describes a workspace update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = 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 ZoneResolutionInfo(_Model): + """Information about how physical zones were resolved to logical zones for each subscription + during scenario execution. + + :ivar mode: The zone targeting mode used for this run. ``logical`` — customer specified logical + zone identifiers directly. ``physical`` — customer specified physical zone identifiers; the + system resolved them to per-subscription logical zones at execution time. Required. Known + values are: "logical" and "physical". + :vartype mode: str or ~azure.mgmt.chaos.models.ZoneResolutionMode + :ivar requested_physical_zones: The physical zone identifiers requested by the customer in the + scenario configuration (e.g., ``["westus2-az1"]``). Empty array when ``mode`` is ``logical``. + Required. + :vartype requested_physical_zones: list[str] + :ivar subscription_zone_mappings: Per-subscription zone resolution results. Each entry maps a + subscription to the logical zone resolved from the requested physical zone. Empty when ``mode`` + is ``logical``. Required. + :vartype subscription_zone_mappings: list[~azure.mgmt.chaos.models.ZoneResolutionMapping] + """ + + mode: Union[str, "_models.ZoneResolutionMode"] = rest_field(visibility=["read"]) + """The zone targeting mode used for this run. ``logical`` — customer specified logical zone + identifiers directly. ``physical`` — customer specified physical zone identifiers; the system + resolved them to per-subscription logical zones at execution time. Required. Known values are: + \"logical\" and \"physical\".""" + requested_physical_zones: list[str] = rest_field(name="requestedPhysicalZones", visibility=["read"]) + """The physical zone identifiers requested by the customer in the scenario configuration (e.g., + ``[\"westus2-az1\"]``). Empty array when ``mode`` is ``logical``. Required.""" + subscription_zone_mappings: list["_models.ZoneResolutionMapping"] = rest_field( + name="subscriptionZoneMappings", visibility=["read"] + ) + """Per-subscription zone resolution results. Each entry maps a subscription to the logical zone + resolved from the requested physical zone. Empty when ``mode`` is ``logical``. Required.""" + + +class ZoneResolutionMapping(_Model): + """Maps a single subscription to its physical-to-logical zone resolutions. + + :ivar subscription_id: The subscription ID (e.g., ``"6b052e15-03d3-4f17-b2e1-be7f07588291"``). + Required. + :vartype subscription_id: str + :ivar zone_mappings: The physical-to-logical zone mappings for this subscription. Required. + :vartype zone_mappings: list[~azure.mgmt.chaos.models.PhysicalToLogicalZoneMapping] + """ + + subscription_id: str = rest_field(name="subscriptionId", visibility=["read"]) + """The subscription ID (e.g., ``\"6b052e15-03d3-4f17-b2e1-be7f07588291\"``). Required.""" + zone_mappings: list["_models.PhysicalToLogicalZoneMapping"] = rest_field(name="zoneMappings", visibility=["read"]) + """The physical-to-logical zone mappings for this subscription. Required.""" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py deleted file mode 100644 index 9f1855f4c806..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py +++ /dev/null @@ -1,2113 +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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class ActionStatus(_serialization.Model): - """Model that represents the an action and its status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar action_name: The name of the action status. - :vartype action_name: str - :ivar action_id: The id of the action status. - :vartype action_id: str - :ivar status: The status of the action. - :vartype status: str - :ivar start_time: String that represents the start time of the action. - :vartype start_time: ~datetime.datetime - :ivar end_time: String that represents the end time of the action. - :vartype end_time: ~datetime.datetime - :ivar targets: The array of targets. - :vartype targets: - list[~azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsProperties] - """ - - _validation = { - "action_name": {"readonly": True}, - "action_id": {"readonly": True}, - "status": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "targets": {"readonly": True}, - } - - _attribute_map = { - "action_name": {"key": "actionName", "type": "str"}, - "action_id": {"key": "actionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "targets": {"key": "targets", "type": "[ExperimentExecutionActionTargetDetailsProperties]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.action_name: Optional[str] = None - self.action_id: Optional[str] = None - self.status: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.targets: Optional[List["_models.ExperimentExecutionActionTargetDetailsProperties"]] = None - - -class BranchStatus(_serialization.Model): - """Model that represents the a list of actions and action statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar branch_name: The name of the branch status. - :vartype branch_name: str - :ivar branch_id: The id of the branch status. - :vartype branch_id: str - :ivar status: The status of the branch. - :vartype status: str - :ivar actions: The array of actions. - :vartype actions: list[~azure.mgmt.chaos.models.ActionStatus] - """ - - _validation = { - "branch_name": {"readonly": True}, - "branch_id": {"readonly": True}, - "status": {"readonly": True}, - "actions": {"readonly": True}, - } - - _attribute_map = { - "branch_name": {"key": "branchName", "type": "str"}, - "branch_id": {"key": "branchId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "actions": {"key": "actions", "type": "[ActionStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.branch_name: Optional[str] = None - self.branch_id: Optional[str] = None - self.status: Optional[str] = None - self.actions: Optional[List["_models.ActionStatus"]] = None - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - self.system_data: Optional["_models.SystemData"] = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.models.SystemData - """ - - -class Capability(ProxyResource): - """Model that represents a Capability resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :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.chaos.models.SystemData - :ivar publisher: String of the Publisher that this Capability extends. - :vartype publisher: str - :ivar target_type: String of the Target Type that this Capability extends. - :vartype target_type: str - :ivar description: Localized string of the description. - :vartype description: str - :ivar parameters_schema: URL to retrieve JSON schema of the Capability parameters. - :vartype parameters_schema: str - :ivar urn: String of the URN for this Capability Type. - :vartype urn: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "publisher": {"readonly": True}, - "target_type": {"readonly": True}, - "description": {"readonly": True}, - "parameters_schema": {"readonly": True, "max_length": 2048}, - "urn": {"readonly": True, "max_length": 2048}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "target_type": {"key": "properties.targetType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "parameters_schema": {"key": "properties.parametersSchema", "type": "str"}, - "urn": {"key": "properties.urn", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.publisher: Optional[str] = None - self.target_type: Optional[str] = None - self.description: Optional[str] = None - self.parameters_schema: Optional[str] = None - self.urn: Optional[str] = None - - -class CapabilityListResult(_serialization.Model): - """Model that represents a list of Capability resources and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The Capability items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.Capability] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Capability]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Capability"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The Capability items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.Capability] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CapabilityType(ProxyResource): - """Model that represents a Capability Type resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :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.chaos.models.SystemData - :ivar publisher: String of the Publisher that this Capability Type extends. - :vartype publisher: str - :ivar target_type: String of the Target Type that this Capability Type extends. - :vartype target_type: str - :ivar display_name: Localized string of the display name. - :vartype display_name: str - :ivar description: Localized string of the description. - :vartype description: str - :ivar parameters_schema: URL to retrieve JSON schema of the Capability Type parameters. - :vartype parameters_schema: str - :ivar urn: String of the URN for this Capability Type. - :vartype urn: str - :ivar kind: String of the kind of this Capability Type. - :vartype kind: str - :ivar azure_rbac_actions: Control plane actions necessary to execute capability type. - :vartype azure_rbac_actions: list[str] - :ivar azure_rbac_data_actions: Data plane actions necessary to execute capability type. - :vartype azure_rbac_data_actions: list[str] - :ivar required_azure_role_definition_ids: Required Azure Role Definition Ids to execute - capability type. - :vartype required_azure_role_definition_ids: list[str] - :ivar runtime_properties: Runtime properties of this Capability Type. - :vartype runtime_properties: ~azure.mgmt.chaos.models.CapabilityTypePropertiesRuntimeProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "publisher": {"readonly": True}, - "target_type": {"readonly": True}, - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "parameters_schema": {"readonly": True, "max_length": 2048}, - "urn": {"readonly": True, "max_length": 2048}, - "kind": {"readonly": True}, - "azure_rbac_actions": {"readonly": True}, - "azure_rbac_data_actions": {"readonly": True}, - "required_azure_role_definition_ids": {"readonly": True}, - "runtime_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "publisher": {"key": "properties.publisher", "type": "str"}, - "target_type": {"key": "properties.targetType", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "parameters_schema": {"key": "properties.parametersSchema", "type": "str"}, - "urn": {"key": "properties.urn", "type": "str"}, - "kind": {"key": "properties.kind", "type": "str"}, - "azure_rbac_actions": {"key": "properties.azureRbacActions", "type": "[str]"}, - "azure_rbac_data_actions": {"key": "properties.azureRbacDataActions", "type": "[str]"}, - "required_azure_role_definition_ids": {"key": "properties.requiredAzureRoleDefinitionIds", "type": "[str]"}, - "runtime_properties": { - "key": "properties.runtimeProperties", - "type": "CapabilityTypePropertiesRuntimeProperties", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.publisher: Optional[str] = None - self.target_type: Optional[str] = None - self.display_name: Optional[str] = None - self.description: Optional[str] = None - self.parameters_schema: Optional[str] = None - self.urn: Optional[str] = None - self.kind: Optional[str] = None - self.azure_rbac_actions: Optional[List[str]] = None - self.azure_rbac_data_actions: Optional[List[str]] = None - self.required_azure_role_definition_ids: Optional[List[str]] = None - self.runtime_properties: Optional["_models.CapabilityTypePropertiesRuntimeProperties"] = None - - -class CapabilityTypeListResult(_serialization.Model): - """Model that represents a list of Capability Type resources and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The CapabilityType items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.CapabilityType] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CapabilityType]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.CapabilityType"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The CapabilityType items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.CapabilityType] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class CapabilityTypePropertiesRuntimeProperties(_serialization.Model): # pylint: disable=name-too-long - """Runtime properties of this Capability Type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar kind: String of the kind of the resource's action type (continuous or discrete). - :vartype kind: str - """ - - _validation = { - "kind": {"readonly": True}, - } - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - - -class ChaosExperimentAction(_serialization.Model): - """Model that represents the base action model. 9 total per experiment. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ContinuousAction, DelayAction, DiscreteAction - - All required parameters must be populated in order to send to server. - - :ivar name: String that represents a Capability URN. Required. - :vartype name: str - :ivar type: Chaos experiment action discriminator type. Required. Known values are: "delay", - "discrete", and "continuous". - :vartype type: str or ~azure.mgmt.chaos.models.ExperimentActionType - """ - - _validation = { - "name": {"required": True, "max_length": 2048}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"continuous": "ContinuousAction", "delay": "DelayAction", "discrete": "DiscreteAction"}} - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: String that represents a Capability URN. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - self.type: Optional[str] = None - - -class ChaosExperimentBranch(_serialization.Model): - """Model that represents a branch in the step. 9 total per experiment. - - All required parameters must be populated in order to send to server. - - :ivar name: String of the branch name. Required. - :vartype name: str - :ivar actions: List of actions. Required. - :vartype actions: list[~azure.mgmt.chaos.models.ChaosExperimentAction] - """ - - _validation = { - "name": {"required": True, "min_length": 1}, - "actions": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "actions": {"key": "actions", "type": "[ChaosExperimentAction]"}, - } - - def __init__(self, *, name: str, actions: List["_models.ChaosExperimentAction"], **kwargs: Any) -> None: - """ - :keyword name: String of the branch name. Required. - :paramtype name: str - :keyword actions: List of actions. Required. - :paramtype actions: list[~azure.mgmt.chaos.models.ChaosExperimentAction] - """ - super().__init__(**kwargs) - self.name = name - self.actions = actions - - -class ChaosExperimentStep(_serialization.Model): - """Model that represents a step in the Experiment resource. - - All required parameters must be populated in order to send to server. - - :ivar name: String of the step name. Required. - :vartype name: str - :ivar branches: List of branches. Required. - :vartype branches: list[~azure.mgmt.chaos.models.ChaosExperimentBranch] - """ - - _validation = { - "name": {"required": True, "min_length": 1}, - "branches": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "branches": {"key": "branches", "type": "[ChaosExperimentBranch]"}, - } - - def __init__(self, *, name: str, branches: List["_models.ChaosExperimentBranch"], **kwargs: Any) -> None: - """ - :keyword name: String of the step name. Required. - :paramtype name: str - :keyword branches: List of branches. Required. - :paramtype branches: list[~azure.mgmt.chaos.models.ChaosExperimentBranch] - """ - super().__init__(**kwargs) - self.name = name - self.branches = branches - - -class ChaosTargetFilter(_serialization.Model): - """Model that represents available filter types that can be applied to a targets list. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ChaosTargetSimpleFilter - - All required parameters must be populated in order to send to server. - - :ivar type: Chaos target filter discriminator type. Required. "Simple" - :vartype type: str or ~azure.mgmt.chaos.models.FilterType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"Simple": "ChaosTargetSimpleFilter"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class ChaosTargetSelector(_serialization.Model): - """Model that represents a selector in the Experiment resource. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ChaosTargetListSelector, ChaosTargetQuerySelector - - All required parameters must be populated in order to send to server. - - :ivar id: String of the selector ID. Required. - :vartype id: str - :ivar type: Chaos target selector discriminator type. Required. Known values are: "List" and - "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - """ - - _validation = { - "id": {"required": True, "min_length": 1}, - "type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "filter": {"key": "filter", "type": "ChaosTargetFilter"}, - } - - _subtype_map = {"type": {"List": "ChaosTargetListSelector", "Query": "ChaosTargetQuerySelector"}} - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: String of the selector ID. Required. - :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - """ - super().__init__(**kwargs) - self.id = id - self.type: Optional[str] = None - self.filter = filter - - -class ChaosTargetListSelector(ChaosTargetSelector): - """Model that represents a list selector. - - All required parameters must be populated in order to send to server. - - :ivar id: String of the selector ID. Required. - :vartype id: str - :ivar type: Chaos target selector discriminator type. Required. Known values are: "List" and - "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - :ivar targets: List of Target references. Required. - :vartype targets: list[~azure.mgmt.chaos.models.TargetReference] - """ - - _validation = { - "id": {"required": True, "min_length": 1}, - "type": {"required": True}, - "targets": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "filter": {"key": "filter", "type": "ChaosTargetFilter"}, - "targets": {"key": "targets", "type": "[TargetReference]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - targets: List["_models.TargetReference"], - filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: String of the selector ID. Required. - :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - :keyword targets: List of Target references. Required. - :paramtype targets: list[~azure.mgmt.chaos.models.TargetReference] - """ - super().__init__(id=id, filter=filter, **kwargs) - self.type: str = "List" - self.targets = targets - - -class ChaosTargetQuerySelector(ChaosTargetSelector): - """Model that represents a query selector. - - All required parameters must be populated in order to send to server. - - :ivar id: String of the selector ID. Required. - :vartype id: str - :ivar type: Chaos target selector discriminator type. Required. Known values are: "List" and - "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - :ivar query_string: Azure Resource Graph (ARG) Query Language query for target resources. - Required. - :vartype query_string: str - :ivar subscription_ids: Subscription id list to scope resource query. Required. - :vartype subscription_ids: list[str] - """ - - _validation = { - "id": {"required": True, "min_length": 1}, - "type": {"required": True}, - "query_string": {"required": True}, - "subscription_ids": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "filter": {"key": "filter", "type": "ChaosTargetFilter"}, - "query_string": {"key": "queryString", "type": "str"}, - "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - query_string: str, - subscription_ids: List[str], - filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: String of the selector ID. Required. - :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter - :keyword query_string: Azure Resource Graph (ARG) Query Language query for target resources. - Required. - :paramtype query_string: str - :keyword subscription_ids: Subscription id list to scope resource query. Required. - :paramtype subscription_ids: list[str] - """ - super().__init__(id=id, filter=filter, **kwargs) - self.type: str = "Query" - self.query_string = query_string - self.subscription_ids = subscription_ids - - -class ChaosTargetSimpleFilter(ChaosTargetFilter): - """Model that represents a simple target filter. - - All required parameters must be populated in order to send to server. - - :ivar type: Chaos target filter discriminator type. Required. "Simple" - :vartype type: str or ~azure.mgmt.chaos.models.FilterType - :ivar parameters: Model that represents the Simple filter parameters. - :vartype parameters: ~azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "parameters": {"key": "parameters", "type": "ChaosTargetSimpleFilterParameters"}, - } - - def __init__( - self, *, parameters: Optional["_models.ChaosTargetSimpleFilterParameters"] = None, **kwargs: Any - ) -> None: - """ - :keyword parameters: Model that represents the Simple filter parameters. - :paramtype parameters: ~azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters - """ - super().__init__(**kwargs) - self.type: str = "Simple" - self.parameters = parameters - - -class ChaosTargetSimpleFilterParameters(_serialization.Model): - """Model that represents the Simple filter parameters. - - :ivar zones: List of Azure availability zones to filter targets by. - :vartype zones: list[str] - """ - - _attribute_map = { - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, *, zones: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword zones: List of Azure availability zones to filter targets by. - :paramtype zones: list[str] - """ - super().__init__(**kwargs) - self.zones = zones - - -class ContinuousAction(ChaosExperimentAction): - """Model that represents a continuous action. - - All required parameters must be populated in order to send to server. - - :ivar name: String that represents a Capability URN. Required. - :vartype name: str - :ivar type: Chaos experiment action discriminator type. Required. Known values are: "delay", - "discrete", and "continuous". - :vartype type: str or ~azure.mgmt.chaos.models.ExperimentActionType - :ivar duration: ISO8601 formatted string that represents a duration. Required. - :vartype duration: ~datetime.timedelta - :ivar parameters: List of key value pairs. Required. - :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :ivar selector_id: String that represents a selector. Required. - :vartype selector_id: str - """ - - _validation = { - "name": {"required": True, "max_length": 2048}, - "type": {"required": True}, - "duration": {"required": True}, - "parameters": {"required": True}, - "selector_id": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "duration": {"key": "duration", "type": "duration"}, - "parameters": {"key": "parameters", "type": "[KeyValuePair]"}, - "selector_id": {"key": "selectorId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - duration: datetime.timedelta, - parameters: List["_models.KeyValuePair"], - selector_id: str, - **kwargs: Any - ) -> None: - """ - :keyword name: String that represents a Capability URN. Required. - :paramtype name: str - :keyword duration: ISO8601 formatted string that represents a duration. Required. - :paramtype duration: ~datetime.timedelta - :keyword parameters: List of key value pairs. Required. - :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :keyword selector_id: String that represents a selector. Required. - :paramtype selector_id: str - """ - super().__init__(name=name, **kwargs) - self.type: str = "continuous" - self.duration = duration - self.parameters = parameters - self.selector_id = selector_id - - -class DelayAction(ChaosExperimentAction): - """Model that represents a delay action. - - All required parameters must be populated in order to send to server. - - :ivar name: String that represents a Capability URN. Required. - :vartype name: str - :ivar type: Chaos experiment action discriminator type. Required. Known values are: "delay", - "discrete", and "continuous". - :vartype type: str or ~azure.mgmt.chaos.models.ExperimentActionType - :ivar duration: ISO8601 formatted string that represents a duration. Required. - :vartype duration: ~datetime.timedelta - """ - - _validation = { - "name": {"required": True, "max_length": 2048}, - "type": {"required": True}, - "duration": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "duration": {"key": "duration", "type": "duration"}, - } - - def __init__(self, *, name: str, duration: datetime.timedelta, **kwargs: Any) -> None: - """ - :keyword name: String that represents a Capability URN. Required. - :paramtype name: str - :keyword duration: ISO8601 formatted string that represents a duration. Required. - :paramtype duration: ~datetime.timedelta - """ - super().__init__(name=name, **kwargs) - self.type: str = "delay" - self.duration = duration - - -class DiscreteAction(ChaosExperimentAction): - """Model that represents a discrete action. - - All required parameters must be populated in order to send to server. - - :ivar name: String that represents a Capability URN. Required. - :vartype name: str - :ivar type: Chaos experiment action discriminator type. Required. Known values are: "delay", - "discrete", and "continuous". - :vartype type: str or ~azure.mgmt.chaos.models.ExperimentActionType - :ivar parameters: List of key value pairs. Required. - :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :ivar selector_id: String that represents a selector. Required. - :vartype selector_id: str - """ - - _validation = { - "name": {"required": True, "max_length": 2048}, - "type": {"required": True}, - "parameters": {"required": True}, - "selector_id": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "parameters": {"key": "parameters", "type": "[KeyValuePair]"}, - "selector_id": {"key": "selectorId", "type": "str"}, - } - - def __init__(self, *, name: str, parameters: List["_models.KeyValuePair"], selector_id: str, **kwargs: Any) -> None: - """ - :keyword name: String that represents a Capability URN. Required. - :paramtype name: str - :keyword parameters: List of key value pairs. Required. - :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :keyword selector_id: String that represents a selector. Required. - :paramtype selector_id: str - """ - super().__init__(name=name, **kwargs) - self.type: str = "discrete" - self.parameters = parameters - self.selector_id = selector_id - - -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 ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.chaos.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.chaos.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[List["_models.ErrorDetail"]] = None - self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.chaos.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.chaos.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - 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: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class Experiment(TrackedResource): - """Model that represents a Experiment resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.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 identity: The managed service identities assigned to this resource. - :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity - :ivar provisioning_state: Most recent provisioning state for the given experiment resource. - Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState - :ivar steps: List of steps. Required. - :vartype steps: list[~azure.mgmt.chaos.models.ChaosExperimentStep] - :ivar selectors: List of selectors. Required. - :vartype selectors: list[~azure.mgmt.chaos.models.ChaosTargetSelector] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "steps": {"required": True}, - "selectors": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "steps": {"key": "properties.steps", "type": "[ChaosExperimentStep]"}, - "selectors": {"key": "properties.selectors", "type": "[ChaosTargetSelector]"}, - } - - def __init__( - self, - *, - location: str, - steps: List["_models.ChaosExperimentStep"], - selectors: List["_models.ChaosTargetSelector"], - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword identity: The managed service identities assigned to this resource. - :paramtype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity - :keyword steps: List of steps. Required. - :paramtype steps: list[~azure.mgmt.chaos.models.ChaosExperimentStep] - :keyword selectors: List of selectors. Required. - :paramtype selectors: list[~azure.mgmt.chaos.models.ChaosTargetSelector] - """ - super().__init__(tags=tags, location=location, **kwargs) - self.identity = identity - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - self.steps = steps - self.selectors = selectors - - -class ExperimentExecution(ProxyResource): - """Model that represents the execution of a Experiment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.models.SystemData - :ivar status: The status of the execution. - :vartype status: str - :ivar started_at: String that represents the start date time. - :vartype started_at: ~datetime.datetime - :ivar stopped_at: String that represents the stop date time. - :vartype stopped_at: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "status": {"readonly": True}, - "started_at": {"readonly": True}, - "stopped_at": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "status": {"key": "properties.status", "type": "str"}, - "started_at": {"key": "properties.startedAt", "type": "iso-8601"}, - "stopped_at": {"key": "properties.stoppedAt", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[str] = None - self.started_at: Optional[datetime.datetime] = None - self.stopped_at: Optional[datetime.datetime] = None - - -class ExperimentExecutionActionTargetDetailsError(_serialization.Model): # pylint: disable=name-too-long - """Model that represents the Experiment action target details error model. - - 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 - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - - -class ExperimentExecutionActionTargetDetailsProperties(_serialization.Model): # pylint: disable=name-too-long - """Model that represents the Experiment action target details properties model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the execution. - :vartype status: str - :ivar target: The target for the action. - :vartype target: str - :ivar target_failed_time: String that represents the failed date time. - :vartype target_failed_time: ~datetime.datetime - :ivar target_completed_time: String that represents the completed date time. - :vartype target_completed_time: ~datetime.datetime - :ivar error: The error of the action. - :vartype error: ~azure.mgmt.chaos.models.ExperimentExecutionActionTargetDetailsError - """ - - _validation = { - "status": {"readonly": True}, - "target": {"readonly": True}, - "target_failed_time": {"readonly": True}, - "target_completed_time": {"readonly": True}, - "error": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "target_failed_time": {"key": "targetFailedTime", "type": "iso-8601"}, - "target_completed_time": {"key": "targetCompletedTime", "type": "iso-8601"}, - "error": {"key": "error", "type": "ExperimentExecutionActionTargetDetailsError"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[str] = None - self.target: Optional[str] = None - self.target_failed_time: Optional[datetime.datetime] = None - self.target_completed_time: Optional[datetime.datetime] = None - self.error: Optional["_models.ExperimentExecutionActionTargetDetailsError"] = None - - -class ExperimentExecutionDetails(_serialization.Model): - """Model that represents the execution details of an Experiment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: String of the resource type. - :vartype type: str - :ivar id: String of the fully qualified resource ID. - :vartype id: str - :ivar name: String of the resource name. - :vartype name: str - :ivar properties: The properties of the experiment execution details. - :vartype properties: ~azure.mgmt.chaos.models.ExperimentExecutionDetailsProperties - """ - - _validation = { - "type": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "ExperimentExecutionDetailsProperties"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id: Optional[str] = None - self.name: Optional[str] = None - self.properties: Optional["_models.ExperimentExecutionDetailsProperties"] = None - - -class ExperimentExecutionDetailsProperties(_serialization.Model): - """Model that represents the extended properties of an experiment execution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of the execution. - :vartype status: str - :ivar started_at: String that represents the start date time. - :vartype started_at: ~datetime.datetime - :ivar stopped_at: String that represents the stop date time. - :vartype stopped_at: ~datetime.datetime - :ivar failure_reason: The reason why the execution failed. - :vartype failure_reason: str - :ivar last_action_at: String that represents the last action date time. - :vartype last_action_at: ~datetime.datetime - :ivar run_information: The information of the experiment run. - :vartype run_information: - ~azure.mgmt.chaos.models.ExperimentExecutionDetailsPropertiesRunInformation - """ - - _validation = { - "status": {"readonly": True}, - "started_at": {"readonly": True}, - "stopped_at": {"readonly": True}, - "failure_reason": {"readonly": True}, - "last_action_at": {"readonly": True}, - "run_information": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "started_at": {"key": "startedAt", "type": "iso-8601"}, - "stopped_at": {"key": "stoppedAt", "type": "iso-8601"}, - "failure_reason": {"key": "failureReason", "type": "str"}, - "last_action_at": {"key": "lastActionAt", "type": "iso-8601"}, - "run_information": {"key": "runInformation", "type": "ExperimentExecutionDetailsPropertiesRunInformation"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[str] = None - self.started_at: Optional[datetime.datetime] = None - self.stopped_at: Optional[datetime.datetime] = None - self.failure_reason: Optional[str] = None - self.last_action_at: Optional[datetime.datetime] = None - self.run_information: Optional["_models.ExperimentExecutionDetailsPropertiesRunInformation"] = None - - -class ExperimentExecutionDetailsPropertiesRunInformation(_serialization.Model): # pylint: disable=name-too-long - """The information of the experiment run. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar steps: The steps of the experiment run. - :vartype steps: list[~azure.mgmt.chaos.models.StepStatus] - """ - - _validation = { - "steps": {"readonly": True}, - } - - _attribute_map = { - "steps": {"key": "steps", "type": "[StepStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.steps: Optional[List["_models.StepStatus"]] = None - - -class ExperimentExecutionListResult(_serialization.Model): - """Model that represents a list of Experiment executions and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The ExperimentExecution items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.ExperimentExecution] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ExperimentExecution]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ExperimentExecution"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The ExperimentExecution items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.ExperimentExecution] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ExperimentListResult(_serialization.Model): - """Model that represents a list of Experiment resources and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The Experiment items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.Experiment] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Experiment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Experiment"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The Experiment items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.Experiment] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ExperimentUpdate(_serialization.Model): - """Describes an experiment update. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar identity: The managed service identities assigned to this resource. - :vartype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The managed service identities assigned to this resource. - :paramtype identity: ~azure.mgmt.chaos.models.ManagedServiceIdentity - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - - -class KeyValuePair(_serialization.Model): - """A map to describe the settings of an action. - - All required parameters must be populated in order to send to server. - - :ivar key: The name of the setting for the action. Required. - :vartype key: str - :ivar value: The value of the setting for the action. Required. - :vartype value: str - """ - - _validation = { - "key": {"required": True, "min_length": 1}, - "value": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "key": {"key": "key", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, key: str, value: str, **kwargs: Any) -> None: - """ - :keyword key: The name of the setting for the action. Required. - :paramtype key: str - :keyword value: The value of the setting for the action. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.key = key - self.value = value - - -class ManagedServiceIdentity(_serialization.Model): - """Managed service identity (system assigned and/or user assigned identities). - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.chaos.models.ManagedServiceIdentityType - :ivar user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, ~azure.mgmt.chaos.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.chaos.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, ~azure.mgmt.chaos.models.UserAssignedIdentity] - """ - 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 Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.chaos.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.chaos.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.chaos.models.ActionType - """ - - _validation = { - "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.chaos.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.is_data_action: Optional[bool] = None - self.display = display - self.origin: Optional[Union[str, "_models.Origin"]] = None - self.action_type: Optional[Union[str, "_models.ActionType"]] = None - - -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider: Optional[str] = None - self.resource: Optional[str] = None - self.operation: Optional[str] = None - self.description: Optional[str] = None - - -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.chaos.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[List["_models.Operation"]] = None - self.next_link: Optional[str] = None - - -class OperationStatusResult(_serialization.Model): - """The current status of an async operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified ID for the async operation. - :vartype id: str - :ivar resource_id: Fully qualified ID of the resource against which the original async - operation was started. - :vartype resource_id: str - :ivar name: Name of the async operation. - :vartype name: str - :ivar status: Operation status. Required. - :vartype status: str - :ivar percent_complete: Percent of the operation that is complete. - :vartype percent_complete: float - :ivar start_time: The start time of the operation. - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time of the operation. - :vartype end_time: ~datetime.datetime - :ivar operations: The operations list. - :vartype operations: list[~azure.mgmt.chaos.models.OperationStatusResult] - :ivar error: If present, details of the operation error. - :vartype error: ~azure.mgmt.chaos.models.ErrorDetail - """ - - _validation = { - "resource_id": {"readonly": True}, - "status": {"required": True}, - "percent_complete": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "percent_complete": {"key": "percentComplete", "type": "float"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "operations": {"key": "operations", "type": "[OperationStatusResult]"}, - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__( - self, - *, - status: str, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - percent_complete: Optional[float] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - operations: Optional[List["_models.OperationStatusResult"]] = None, - error: Optional["_models.ErrorDetail"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Fully qualified ID for the async operation. - :paramtype id: str - :keyword name: Name of the async operation. - :paramtype name: str - :keyword status: Operation status. Required. - :paramtype status: str - :keyword percent_complete: Percent of the operation that is complete. - :paramtype percent_complete: float - :keyword start_time: The start time of the operation. - :paramtype start_time: ~datetime.datetime - :keyword end_time: The end time of the operation. - :paramtype end_time: ~datetime.datetime - :keyword operations: The operations list. - :paramtype operations: list[~azure.mgmt.chaos.models.OperationStatusResult] - :keyword error: If present, details of the operation error. - :paramtype error: ~azure.mgmt.chaos.models.ErrorDetail - """ - super().__init__(**kwargs) - self.id = id - self.resource_id: Optional[str] = None - self.name = name - self.status = status - self.percent_complete = percent_complete - self.start_time = start_time - self.end_time = end_time - self.operations = operations - self.error = error - - -class StepStatus(_serialization.Model): - """Model that represents the a list of branches and branch statuses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar step_name: The name of the step. - :vartype step_name: str - :ivar step_id: The id of the step. - :vartype step_id: str - :ivar status: The value of the status of the step. - :vartype status: str - :ivar branches: The array of branches. - :vartype branches: list[~azure.mgmt.chaos.models.BranchStatus] - """ - - _validation = { - "step_name": {"readonly": True}, - "step_id": {"readonly": True}, - "status": {"readonly": True}, - "branches": {"readonly": True}, - } - - _attribute_map = { - "step_name": {"key": "stepName", "type": "str"}, - "step_id": {"key": "stepId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "branches": {"key": "branches", "type": "[BranchStatus]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.step_name: Optional[str] = None - self.step_id: Optional[str] = None - self.status: Optional[str] = None - self.branches: Optional[List["_models.BranchStatus"]] = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.chaos.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.chaos.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.chaos.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.chaos.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class Target(ProxyResource): - """Model that represents a Target resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.chaos.models.SystemData - :ivar properties: The properties of the target resource. Required. - :vartype properties: dict[str, any] - :ivar location: Azure resource location. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "properties": {"key": "properties", "type": "{object}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, properties: Dict[str, Any], location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword properties: The properties of the target resource. Required. - :paramtype properties: dict[str, any] - :keyword location: Azure resource location. - :paramtype location: str - """ - super().__init__(**kwargs) - self.properties = properties - self.location = location - - -class TargetListResult(_serialization.Model): - """Model that represents a list of Target resources and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The Target items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.Target] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Target]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.Target"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The Target items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.Target] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class TargetReference(_serialization.Model): - """Model that represents a reference to a Target in the selector. - - All required parameters must be populated in order to send to server. - - :ivar type: Enum of the Target reference type. Required. "ChaosTarget" - :vartype type: str or ~azure.mgmt.chaos.models.TargetReferenceType - :ivar id: String of the resource ID of a Target resource. Required. - :vartype id: str - """ - - _validation = { - "type": {"required": True}, - "id": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.TargetReferenceType"], - id: str, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword type: Enum of the Target reference type. Required. "ChaosTarget" - :paramtype type: str or ~azure.mgmt.chaos.models.TargetReferenceType - :keyword id: String of the resource ID of a Target resource. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.type = type - self.id = id - - -class TargetType(ProxyResource): - """Model that represents a Target Type resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :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.chaos.models.SystemData - :ivar display_name: Localized string of the display name. - :vartype display_name: str - :ivar description: Localized string of the description. - :vartype description: str - :ivar properties_schema: URL to retrieve JSON schema of the Target Type properties. - :vartype properties_schema: str - :ivar resource_types: List of resource types this Target Type can extend. - :vartype resource_types: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "display_name": {"readonly": True}, - "description": {"readonly": True}, - "properties_schema": {"readonly": True, "max_length": 2048}, - "resource_types": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "properties_schema": {"key": "properties.propertiesSchema", "type": "str"}, - "resource_types": {"key": "properties.resourceTypes", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_name: Optional[str] = None - self.description: Optional[str] = None - self.properties_schema: Optional[str] = None - self.resource_types: Optional[List[str]] = None - - -class TargetTypeListResult(_serialization.Model): - """Model that represents a list of Target Type resources and a link for pagination. - - All required parameters must be populated in order to send to server. - - :ivar value: The TargetType items on this page. Required. - :vartype value: list[~azure.mgmt.chaos.models.TargetType] - :ivar next_link: The link to the next page of items. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TargetType]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.TargetType"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: The TargetType items on this page. Required. - :paramtype value: list[~azure.mgmt.chaos.models.TargetType] - :keyword next_link: The link to the next page of items. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UserAssignedIdentity(_serialization.Model): - """User assigned identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the assigned identity. - :vartype principal_id: str - :ivar client_id: The client ID of the 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 diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_patch.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_patch.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py index 66eddae45563..f4cff5a39c7c 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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 @@ -12,26 +12,42 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import CapabilitiesOperations # type: ignore from ._operations import Operations # type: ignore -from ._experiments_operations import ExperimentsOperations # type: ignore -from ._operation_statuses_operations import OperationStatusesOperations # type: ignore -from ._target_types_operations import TargetTypesOperations # type: ignore -from ._capability_types_operations import CapabilityTypesOperations # type: ignore -from ._targets_operations import TargetsOperations # type: ignore -from ._capabilities_operations import CapabilitiesOperations # type: ignore +from ._operations import TargetsOperations # type: ignore +from ._operations import CapabilityTypesOperations # type: ignore +from ._operations import ExperimentsOperations # type: ignore +from ._operations import PrivateAccessesOperations # type: ignore +from ._operations import ActionsOperations # type: ignore +from ._operations import ActionVersionsOperations # type: ignore +from ._operations import TargetTypesOperations # type: ignore +from ._operations import OperationStatusesOperations # type: ignore +from ._operations import WorkspacesOperations # type: ignore +from ._operations import DiscoveredResourcesOperations # type: ignore +from ._operations import ScenariosOperations # type: ignore +from ._operations import ScenarioRunsOperations # type: ignore +from ._operations import ScenarioConfigurationsOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "CapabilitiesOperations", "Operations", + "TargetsOperations", + "CapabilityTypesOperations", "ExperimentsOperations", - "OperationStatusesOperations", + "PrivateAccessesOperations", + "ActionsOperations", + "ActionVersionsOperations", "TargetTypesOperations", - "CapabilityTypesOperations", - "TargetsOperations", - "CapabilitiesOperations", + "OperationStatusesOperations", + "WorkspacesOperations", + "DiscoveredResourcesOperations", + "ScenariosOperations", + "ScenarioRunsOperations", + "ScenarioConfigurationsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py deleted file mode 100644 index da9b6e367b2c..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py +++ /dev/null @@ -1,744 +0,0 @@ -# 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. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - subscription_id: str, - *, - continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - "capabilityName": _SERIALIZER.url( - "capability_name", capability_name, "str", pattern=r"^[a-zA-Z0-9\-\.]+-\d\.\d$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_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-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - "capabilityName": _SERIALIZER.url( - "capability_name", capability_name, "str", pattern=r"^[a-zA-Z0-9\-\.]+-\d\.\d$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - "capabilityName": _SERIALIZER.url( - "capability_name", capability_name, "str", pattern=r"^[a-zA-Z0-9\-\.]+-\d\.\d$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class CapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`capabilities` 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: ChaosManagementClientConfiguration = 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_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.Capability"]: - """Get a list of Capability resources that extend a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Capability or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Capability] - :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.CapabilityListResult] = 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_list_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - 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("CapabilityListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - **kwargs: Any - ) -> _models.Capability: - """Get a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :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.Capability] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: _models.Capability, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Capability - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - resource: Union[_models.Capability, IO[bytes]], - **kwargs: Any - ) -> _models.Capability: - """Create or update a Capability resource that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :param resource: Capability resource to be created or updated. Is either a Capability type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Capability or IO[bytes] - :return: Capability or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Capability - :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 {}) - - 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.Capability] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Capability") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Capability", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - capability_name: str, - **kwargs: Any - ) -> None: - """Delete a Capability that extends a Target resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param capability_name: String that represents a Capability resource name. Required. - :type capability_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - capability_name=capability_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py deleted file mode 100644 index 37cc2d5d0825..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py +++ /dev/null @@ -1,278 +0,0 @@ -# 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. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - location: str, - target_type_name: str, - subscription_id: str, - *, - continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - location: str, target_type_name: str, capability_type_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - "capabilityTypeName": _SERIALIZER.url( - "capability_type_name", capability_type_name, "str", pattern=r"^[a-zA-Z0-9\-\.]+-\d\.\d$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class CapabilityTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`capability_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: ChaosManagementClientConfiguration = 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, location: str, target_type_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.CapabilityType"]: - """Get a list of Capability Type resources for given Target Type and location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either CapabilityType or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.CapabilityType] - :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.CapabilityTypeListResult] = 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_list_request( - location=location, - target_type_name=target_type_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - 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("CapabilityTypeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, location: str, target_type_name: str, capability_type_name: str, **kwargs: Any - ) -> _models.CapabilityType: - """Get a Capability Type resource for given Target Type and location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :param capability_type_name: String that represents a Capability Type resource name. Required. - :type capability_type_name: str - :return: CapabilityType or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.CapabilityType - :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.CapabilityType] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - target_type_name=target_type_name, - capability_type_name=capability_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CapabilityType", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py deleted file mode 100644 index cacec41fb859..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py +++ /dev/null @@ -1,1637 +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 -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_all_request( - subscription_id: str, - *, - running: Optional[bool] = None, - continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if running is not None: - _params["running"] = _SERIALIZER.query("running", running, "bool") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_group_name: str, - subscription_id: str, - *, - running: Optional[bool] = None, - continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if running is not None: - _params["running"] = _SERIALIZER.query("running", running, "bool") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, experiment_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, experiment_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-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, experiment_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-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, experiment_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request( - resource_group_name: str, experiment_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_all_executions_request( - resource_group_name: str, experiment_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_execution_request( - resource_group_name: str, experiment_name: str, execution_id: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - "executionId": _SERIALIZER.url( - "execution_id", - execution_id, - "str", - pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_execution_details_request( - resource_group_name: str, experiment_name: str, execution_id: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - "executionId": _SERIALIZER.url( - "execution_id", - execution_id, - "str", - pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_request( - resource_group_name: str, experiment_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start", - ) - 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 - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ExperimentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`experiments` 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: ChaosManagementClientConfiguration = 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_all( - self, running: Optional[bool] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.Experiment"]: - """Get a list of Experiment resources in a subscription. - - :param running: Optional value that indicates whether to filter results based on if the - Experiment is currently running. If null, then the results will not be filtered. Default value - is None. - :type running: bool - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Experiment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Experiment] - :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.ExperimentListResult] = 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_list_all_request( - subscription_id=self._config.subscription_id, - running=running, - continuation_token_parameter=continuation_token_parameter, - 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("ExperimentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list( - self, - resource_group_name: str, - running: Optional[bool] = None, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.Experiment"]: - """Get a list of Experiment resources in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param running: Optional value that indicates whether to filter results based on if the - Experiment is currently running. If null, then the results will not be filtered. Default value - is None. - :type running: bool - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Experiment or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Experiment] - :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.ExperimentListResult] = 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_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - running=running, - continuation_token_parameter=continuation_token_parameter, - 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("ExperimentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> _models.Experiment: - """Get a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :return: Experiment or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Experiment - :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.Experiment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Experiment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - experiment_name: str, - resource: Union[_models.Experiment, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Experiment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: _models.Experiment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Experiment - :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 Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - experiment_name: str, - resource: Union[_models.Experiment, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """Create or update a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param resource: Experiment resource to be created or updated. Is either a Experiment type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Experiment or IO[bytes] - :return: An instance of LROPoller that returns either Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :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.Experiment] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - resource=resource, - 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("Experiment", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Experiment].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Experiment]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - experiment_name: str, - properties: Union[_models.ExperimentUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "ExperimentUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: _models.ExperimentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Required. - :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate - :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 Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Required. - :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 Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - experiment_name: str, - properties: Union[_models.ExperimentUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Experiment]: - """The operation to update an experiment. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param properties: Parameters supplied to the Update experiment operation. Is either a - ExperimentUpdate type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Experiment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] - :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.Experiment] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - properties=properties, - 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("Experiment", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Experiment].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Experiment]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_delete_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: - """Delete a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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 _cancel_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: - """Cancel a running Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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._cancel_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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_all_executions( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> ItemPaged["_models.ExperimentExecution"]: - """Get a list of executions of an Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :return: An iterator like instance of either ExperimentExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] - :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.ExperimentExecutionListResult] = 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_list_all_executions_request( - resource_group_name=resource_group_name, - experiment_name=experiment_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), 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("ExperimentExecutionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_execution( - self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any - ) -> _models.ExperimentExecution: - """Get an execution of an Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param execution_id: GUID that represents a Experiment execution detail. Required. - :type execution_id: str - :return: ExperimentExecution or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentExecution - :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.ExperimentExecution] = kwargs.pop("cls", None) - - _request = build_get_execution_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - execution_id=execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentExecution", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def execution_details( - self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any - ) -> _models.ExperimentExecutionDetails: - """Execution details of an experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: str - :param execution_id: GUID that represents a Experiment execution detail. Required. - :type execution_id: str - :return: ExperimentExecutionDetails or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentExecutionDetails - :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.ExperimentExecutionDetails] = kwargs.pop("cls", None) - - _request = build_execution_details_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - execution_id=execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentExecutionDetails", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _start_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(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) - - _request = build_start_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: - """Start a Experiment resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :type experiment_name: 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._start_initial( - resource_group_name=resource_group_name, - experiment_name=experiment_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, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[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 diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py deleted file mode 100644 index 384d0e708d34..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# 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. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(location: str, operation_id: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationStatuses/{operationId}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class OperationStatusesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`operation_statuses` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: - """Returns the current status of an async operation. - - :param location: The name of the Azure region. Required. - :type location: str - :param operation_id: The ID of an ongoing async operation. Required. - :type operation_id: str - :return: OperationStatusResult or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.OperationStatusResult - :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.OperationStatusResult] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatusResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py index 42173df24ca8..de195cc50f0c 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py @@ -1,12 +1,15 @@ +# 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. +# 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 typing import Any, Callable, Dict, Optional, TypeVar +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -16,57 +19,8719 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._configuration import ChaosManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from .._validation import api_version_validation +JSON = MutableMapping[str, Any] T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_all_request(**kwargs: Any) -> HttpRequest: +def build_capabilities_get_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Chaos/operations") + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + "capabilityName": _SERIALIZER.url("capability_name", capability_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capabilities_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + "capabilityName": _SERIALIZER.url("capability_name", capability_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capabilities_delete_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + "capabilityName": _SERIALIZER.url("capability_name", capability_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_capabilities_list_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + subscription_id: str, + *, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operations_list_all_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.Chaos/operations" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_targets_get_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_targets_create_or_update_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_targets_delete_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + "targetName": _SERIALIZER.url("target_name", target_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_targets_list_request( + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + subscription_id: str, + *, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentProviderNamespace": _SERIALIZER.url("parent_provider_namespace", parent_provider_namespace, "str"), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, "str"), + "parentResourceName": _SERIALIZER.url("parent_resource_name", parent_resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capability_types_get_request( + location: str, target_type_name: str, capability_type_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str"), + "capabilityTypeName": _SERIALIZER.url("capability_type_name", capability_type_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capability_types_list_request( + location: str, + target_type_name: str, + subscription_id: str, + *, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_get_request( + resource_group_name: str, experiment_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, experiment_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_update_request( + resource_group_name: str, experiment_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_delete_request( + resource_group_name: str, experiment_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_experiments_list_request( + resource_group_name: str, + subscription_id: str, + *, + running: Optional[bool] = None, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments" + 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 running is not None: + _params["running"] = _SERIALIZER.query("running", running, "bool") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_list_all_request( + subscription_id: str, + *, + running: Optional[bool] = None, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if running is not None: + _params["running"] = _SERIALIZER.query("running", running, "bool") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_cancel_request( + resource_group_name: str, experiment_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_experiments_start_request( + resource_group_name: str, experiment_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_experiments_get_execution_request( + resource_group_name: str, experiment_name: str, execution_id: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + "executionId": _SERIALIZER.url("execution_id", execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_list_all_executions_request( # pylint: disable=name-too-long + resource_group_name: str, experiment_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_experiments_execution_details_request( # pylint: disable=name-too-long + resource_group_name: str, experiment_name: str, execution_id: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "experimentName": _SERIALIZER.url("experiment_name", experiment_name, "str"), + "executionId": _SERIALIZER.url("execution_id", execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_get_request( + resource_group_name: str, private_access_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, private_access_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_update_request( + resource_group_name: str, private_access_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_delete_request( + resource_group_name: str, private_access_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_accesses_list_request( + resource_group_name: str, subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses" + ) + 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 continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_list_all_request( + subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/privateAccesses" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_get_private_link_resources_request( # pylint: disable=name-too-long + resource_group_name: str, private_access_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_get_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_accesses_delete_a_private_endpoint_connection_request( # pylint: disable=name-too-long + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_accesses_list_private_endpoint_connections_request( # pylint: disable=name-too-long + resource_group_name: str, private_access_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "privateAccessName": _SERIALIZER.url("private_access_name", private_access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_actions_get_request(location: str, action_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/actions/{actionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "actionName": _SERIALIZER.url("action_name", action_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_actions_list_request( + location: str, subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/actions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_action_versions_get_request( + location: str, action_name: str, version_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/actions/{actionName}/versions/{versionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "actionName": _SERIALIZER.url("action_name", action_name, "str"), + "versionName": _SERIALIZER.url("version_name", version_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_action_versions_list_request( + location: str, + action_name: str, + subscription_id: str, + *, + continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/actions/{actionName}/versions" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "actionName": _SERIALIZER.url("action_name", action_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_target_types_get_request( + location: str, target_type_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_target_types_list_request( + location: str, subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operation_statuses_get_request( + location: str, operation_id: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationStatuses/{operationId}" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_get_request( + resource_group_name: str, workspace_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, workspace_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_update_request( + resource_group_name: str, workspace_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_delete_request( + resource_group_name: str, workspace_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspaces_list_request( + resource_group_name: str, subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces" + 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 continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_list_all_request( + subscription_id: str, *, continuation_token_parameter: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/workspaces" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspaces_refresh_recommendations_request( # pylint: disable=name-too-long + resource_group_name: str, workspace_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/refreshRecommendations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_discovered_resources_get_request( + resource_group_name: str, workspace_name: str, discovered_resource_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/discoveredResources/{discoveredResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "discoveredResourceName": _SERIALIZER.url("discovered_resource_name", discovered_resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_discovered_resources_list_by_workspace_request( # pylint: disable=name-too-long + resource_group_name: str, workspace_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/discoveredResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenarios_get_request( + resource_group_name: str, workspace_name: str, scenario_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenarios_create_or_update_request( + resource_group_name: str, workspace_name: str, scenario_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenarios_delete_request( + resource_group_name: str, workspace_name: str, scenario_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_scenarios_list_all_request( + resource_group_name: str, workspace_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_runs_get_request( + resource_group_name: str, workspace_name: str, scenario_name: str, run_id: 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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/runs/{runId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_runs_list_all_request( + resource_group_name: str, workspace_name: str, scenario_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/runs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_runs_cancel_request( + resource_group_name: str, workspace_name: str, scenario_name: str, run_id: 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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/runs/{runId}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "runId": _SERIALIZER.url("run_id", run_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_scenario_configurations_get_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_configurations_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_configurations_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_scenario_configurations_list_all_request( # pylint: disable=name-too-long + resource_group_name: str, workspace_name: str, scenario_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", "2026-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scenario_configurations_execute_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}/execute" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_scenario_configurations_validate_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_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", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}/validate" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_scenario_configurations_fix_resource_permissions_request( # pylint: disable=name-too-long + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-05-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/workspaces/{workspaceName}/scenarios/{scenarioName}/configurations/{scenarioConfigurationName}/fixResourcePermissions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "scenarioName": _SERIALIZER.url("scenario_name", scenario_name, "str"), + "scenarioConfigurationName": _SERIALIZER.url("scenario_configuration_name", scenario_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`capabilities` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> _models.Capability: + """Get a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :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.Capability] = kwargs.pop("cls", None) + + _request = build_capabilities_get_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: _models.Capability, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Capability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + resource: Union[_models.Capability, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Capability: + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :param resource: Capability resource to be created or updated. Is one of the following types: + Capability, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Capability or JSON or IO[bytes] + :return: Capability. The Capability is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Capability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Capability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_capabilities_create_or_update_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Capability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> None: + """Delete a Capability that extends a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param capability_name: String that represents a Capability resource name. Required. + :type capability_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_capabilities_delete_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + capability_name=capability_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Capability"]: + """Get a list of Capability resources that extend a Target resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Capability + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Capability] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Capability]] = 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_capabilities_list_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Capability], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`operations` 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: ChaosManagementClientConfiguration = 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_all(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_all_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TargetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`targets` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> _models.Target: + """Get a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :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.Target] = kwargs.pop("cls", None) + + _request = build_targets_get_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Target, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: _models.Target, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Target + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + resource: Union[_models.Target, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Target: + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :param resource: Target resource to be created or updated. Is one of the following types: + Target, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Target or JSON or IO[bytes] + :return: Target. The Target is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Target + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Target] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_targets_create_or_update_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Target, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> None: + """Delete a Target resource that extends a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. Required. + :type target_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_targets_delete_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + target_name=target_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + *, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Target"]: + """Get a list of Target resources that extend a tracked regional resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parent_provider_namespace: The parent resource provider namespace. Required. + :type parent_provider_namespace: str + :param parent_resource_type: The parent resource type. Required. + :type parent_resource_type: str + :param parent_resource_name: The parent resource name. Required. + :type parent_resource_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Target + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Target] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Target]] = 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_targets_list_request( + resource_group_name=resource_group_name, + parent_provider_namespace=parent_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource_name=parent_resource_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Target], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CapabilityTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`capability_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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, location: str, target_type_name: str, capability_type_name: str, **kwargs: Any + ) -> _models.CapabilityType: + """Get a Capability Type resource for given Target Type and location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :param capability_type_name: String that represents a Capability Type resource name. Required. + :type capability_type_name: str + :return: CapabilityType. The CapabilityType is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.CapabilityType + :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.CapabilityType] = kwargs.pop("cls", None) + + _request = build_capability_types_get_request( + location=location, + target_type_name=target_type_name, + capability_type_name=capability_type_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CapabilityType, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, target_type_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.CapabilityType"]: + """Get a list of Capability Type resources for given Target Type and location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of CapabilityType + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.CapabilityType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityType]] = 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_capability_types_list_request( + location=location, + target_type_name=target_type_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.CapabilityType], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ExperimentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`experiments` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> _models.Experiment: + """Get a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: Experiment. The Experiment is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Experiment + :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.Experiment] = kwargs.pop("cls", None) + + _request = build_experiments_get_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Experiment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + experiment_name: str, + resource: Union[_models.Experiment, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_experiments_create_or_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: _models.Experiment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Experiment + :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 Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: 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 Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + resource: Union[_models.Experiment, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """Create or update a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param resource: Experiment resource to be created or updated. Is one of the following types: + Experiment, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Experiment or JSON or IO[bytes] + :return: An instance of LROPoller that returns Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Experiment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Experiment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + experiment_name: str, + properties: Union[_models.ExperimentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_experiments_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: _models.ExperimentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate + :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 Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :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: An instance of LROPoller that returns Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Required. + :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 Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + experiment_name: str, + properties: Union[_models.ExperimentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Experiment]: + """The operation to update an experiment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param properties: Parameters supplied to the Update experiment operation. Is one of the + following types: ExperimentUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.ExperimentUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Experiment. The Experiment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Experiment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Experiment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_delete_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + def begin_delete(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + *, + running: Optional[bool] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Experiment"]: + """Get a list of Experiment resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. Default value + is None. + :paramtype running: bool + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Experiment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Experiment]] = 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_experiments_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + running=running, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Experiment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_all( + self, *, running: Optional[bool] = None, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Experiment"]: + """Get a list of Experiment resources in a subscription. + + :keyword running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. Default value + is None. + :paramtype running: bool + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Experiment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Experiment]] = 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_experiments_list_all_request( + subscription_id=self._config.subscription_id, + running=running, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Experiment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _cancel_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_cancel_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + def begin_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: + """Cancel a running Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cancel_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _start_initial(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_experiments_start_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + def begin_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: + """Start a Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get_execution( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecution: + """Get an execution of an Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_id: str + :return: ExperimentExecution. The ExperimentExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ExperimentExecution + :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.ExperimentExecution] = kwargs.pop("cls", None) + + _request = build_experiments_get_execution_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + execution_id=execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExperimentExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_all_executions( + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> ItemPaged["_models.ExperimentExecution"]: + """Get a list of executions of an Experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :return: An iterator like instance of ExperimentExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExperimentExecution]] = 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_experiments_list_all_executions_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.ExperimentExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def execution_details( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecutionDetails: + """Execution details of an experiment resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :type experiment_name: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_id: str + :return: ExperimentExecutionDetails. The ExperimentExecutionDetails is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.ExperimentExecutionDetails + :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.ExperimentExecutionDetails] = kwargs.pop("cls", None) + + _request = build_experiments_execution_details_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + execution_id=execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExperimentExecutionDetails, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PrivateAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`private_accesses` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> _models.PrivateAccess: + """Get a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: PrivateAccess. The PrivateAccess is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :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.PrivateAccess] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateAccess, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + private_access_name: str, + resource: Union[_models.PrivateAccess, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_accesses_create_or_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: _models.PrivateAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.PrivateAccess + :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 PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: 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 PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_access_name: str, + resource: Union[_models.PrivateAccess, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Create or update a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param resource: private access resource to be created or updated. Is one of the following + types: PrivateAccess, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.PrivateAccess or JSON or IO[bytes] + :return: An instance of LROPoller that returns PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateAccess] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateAccess, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateAccess].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateAccess]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + private_access_name: str, + properties: Union[_models.PrivateAccessPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_accesses_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: _models.PrivateAccessPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :type properties: ~azure.mgmt.chaos.models.PrivateAccessPatch + :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 PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :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: An instance of LROPoller that returns PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Required. + :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 PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + private_access_name: str, + properties: Union[_models.PrivateAccessPatch, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateAccess]: + """Patch a private access tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param properties: private access resource's tags to be updated. Is one of the following types: + PrivateAccessPatch, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.PrivateAccessPatch or JSON or IO[bytes] + :return: An instance of LROPoller that returns PrivateAccess. The PrivateAccess is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateAccess] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateAccess, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateAccess].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateAccess]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_accesses_delete_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + def begin_delete(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a private access. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.PrivateAccess"]: + """Get a list of private access resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of PrivateAccess + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateAccess]] = 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_private_accesses_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.PrivateAccess], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_all( + self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.PrivateAccess"]: + """Get a list of private access resources in a subscription. + + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of PrivateAccess + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateAccess]] = 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_private_accesses_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.PrivateAccess], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_private_link_resources( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateLinkResourceListResult + :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_private_link_resources_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_accesses_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_a_private_endpoint_connection_initial( # pylint: disable=name-too-long + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_accesses_delete_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + def begin_delete_a_private_endpoint_connection( # pylint: disable=name-too-long + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a private access resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = 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_private_accesses_list_private_endpoint_connections_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`actions` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={"2026-05-01-preview": ["api_version", "subscription_id", "location", "action_name", "accept"]}, + api_versions_list=["2026-05-01-preview"], + ) + def get(self, location: str, action_name: str, **kwargs: Any) -> _models.Action: + """Get an Action resource for a given location. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :return: Action. The Action is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Action + :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.Action] = kwargs.pop("cls", None) + + _request = build_actions_get_request( + location=location, + action_name=action_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Action, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, location: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Action"]: + """Get a list of Action resources for a given location. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Action + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Action] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Action]] = 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_actions_list_request( + location=location, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Action], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ActionVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`action_versions` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "action_name", + "version_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get(self, location: str, action_name: str, version_name: str, **kwargs: Any) -> _models.ActionVersion: + """Get an Action Version resource for a given location and action. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :param version_name: String that represents an Action Version resource name. Required. + :type version_name: str + :return: ActionVersion. The ActionVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ActionVersion + :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.ActionVersion] = kwargs.pop("cls", None) + + _request = build_action_versions_get_request( + location=location, + action_name=action_name, + version_name=version_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ActionVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "location", + "action_name", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, location: str, action_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ActionVersion"]: + """Get a list of Action Version resources for a given location and action. + + :param location: The name of the Azure region. Required. + :type location: str + :param action_name: String that represents an Action resource name. Required. + :type action_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of ActionVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ActionVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ActionVersion]] = 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_action_versions_list_request( + location=location, + action_name=action_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.ActionVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TargetTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`target_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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, target_type_name: str, **kwargs: Any) -> _models.TargetType: + """Get a Target Type resources for given location. + + :param location: The name of the Azure region. Required. + :type location: str + :param target_type_name: String that represents a Target Type resource name. Required. + :type target_type_name: str + :return: TargetType. The TargetType is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.TargetType + :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.TargetType] = kwargs.pop("cls", None) + + _request = build_target_types_get_request( + location=location, + target_type_name=target_type_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TargetType, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, location: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.TargetType"]: + """Get a list of Target Type resources for given location. + + :param location: The name of the Azure region. Required. + :type location: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of TargetType + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.TargetType] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TargetType]] = 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_target_types_list_request( + location=location, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.TargetType], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OperationStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`operation_statuses` 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: ChaosManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationStatusResult: + """Returns the current status of an async operation. + + :param location: The location name. Required. + :type location: str + :param operation_id: The ID of an ongoing async operation. Required. + :type operation_id: str + :return: OperationStatusResult. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.OperationStatusResult + :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.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_statuses_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`workspaces` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: + """Get a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: Workspace. The Workspace is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Workspace + :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.Workspace] = kwargs.pop("cls", None) + + _request = build_workspaces_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Workspace, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _create_or_update_initial( + self, + resource_group_name: str, + workspace_name: str, + resource: Union[_models.Workspace, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspaces_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: _models.Workspace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: ~azure.mgmt.chaos.models.Workspace + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: 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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + resource: Union[_models.Workspace, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Create or update a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param resource: Workspace resource to be created or updated. Is one of the following types: + Workspace, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Workspace or JSON or IO[bytes] + :return: An instance of LROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Workspace, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Workspace].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _update_initial( + self, + resource_group_name: str, + workspace_name: str, + properties: Union[_models.WorkspaceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspaces_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: _models.WorkspaceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :type properties: ~azure.mgmt.chaos.models.WorkspaceUpdate + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :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: An instance of LROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Required. + :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 Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + properties: Union[_models.WorkspaceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """The operation to update a Workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param properties: Parameters supplied to the Update Workspace operation. Is one of the + following types: WorkspaceUpdate, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.chaos.models.WorkspaceUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Workspace. The Workspace is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Workspace, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Workspace].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _delete_initial(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspaces_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Workspace resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "continuation_token_parameter", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list( + self, resource_group_name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Workspace"]: + """Get a list of Workspace resources in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Workspace + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Workspace]] = 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_workspaces_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Workspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "continuation_token_parameter", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Workspace"]: + """Get a list of all Workspace resources in a subscription. + + :keyword continuation_token_parameter: String that sets the continuation token. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of Workspace + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Workspace]] = 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_workspaces_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + 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), 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.Workspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _refresh_recommendations_initial( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspaces_refresh_recommendations_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_refresh_recommendations( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> LROPoller[_models.WorkspaceEvaluation]: + """Refreshes recommendation status for all scenarios in a given workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An instance of LROPoller that returns WorkspaceEvaluation. The WorkspaceEvaluation is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.WorkspaceEvaluation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkspaceEvaluation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_recommendations_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.WorkspaceEvaluation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WorkspaceEvaluation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WorkspaceEvaluation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DiscoveredResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`discovered_resources` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "discovered_resource_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get( + self, resource_group_name: str, workspace_name: str, discovered_resource_name: str, **kwargs: Any + ) -> _models.DiscoveredResource: + """Get a discovered resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param discovered_resource_name: Name of the discovered resource. Required. + :type discovered_resource_name: str + :return: DiscoveredResource. The DiscoveredResource is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.DiscoveredResource + :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.DiscoveredResource] = kwargs.pop("cls", None) + + _request = build_discovered_resources_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + discovered_resource_name=discovered_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiscoveredResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_by_workspace( + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> ItemPaged["_models.DiscoveredResource"]: + """Get a list of discovered resources for a workspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An iterator like instance of DiscoveredResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.DiscoveredResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiscoveredResource]] = 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_discovered_resources_list_by_workspace_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.DiscoveredResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ScenariosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`scenarios` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get(self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any) -> _models.Scenario: + """Get a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :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.Scenario] = kwargs.pop("cls", None) + + _request = build_scenarios_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Scenario, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: _models.Scenario, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.chaos.models.Scenario + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + resource: Union[_models.Scenario, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Scenario: + """Create or update a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param resource: Resource create parameters. Is one of the following types: Scenario, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.Scenario or JSON or IO[bytes] + :return: Scenario. The Scenario is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.Scenario + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Scenario] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_scenarios_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Scenario, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> None: + """Delete a scenario. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_scenarios_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": ["api_version", "subscription_id", "resource_group_name", "workspace_name", "accept"] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> ItemPaged["_models.Scenario"]: + """Get a list of scenarios. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :return: An iterator like instance of Scenario + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Scenario] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Scenario]] = 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_scenarios_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.Scenario], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ScenarioRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`scenario_runs` 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: ChaosManagementClientConfiguration = 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "run_id", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get( + self, resource_group_name: str, workspace_name: str, scenario_name: str, run_id: str, **kwargs: Any + ) -> _models.ScenarioRun: + """Get a scenario run. + + Get a scenario run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param run_id: The name of the ScenarioRun. Required. + :type run_id: str + :return: ScenarioRun. The ScenarioRun is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ScenarioRun + :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.ScenarioRun] = kwargs.pop("cls", None) + + _request = build_scenario_runs_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + run_id=run_id, + 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, 202]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ScenarioRun, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> ItemPaged["_models.ScenarioRun"]: + """Get a list of scenario runs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: An iterator like instance of ScenarioRun + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ScenarioRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ScenarioRun]] = 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_scenario_runs_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), 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.ScenarioRun], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return ItemPaged(get_next, extract_data) - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "run_id", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def cancel( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, workspace_name: str, scenario_name: str, run_id: str, **kwargs: Any + ) -> None: + """Cancel the currently running scenario execution. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param run_id: The name of the ScenarioRun. Required. + :type run_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 {}) -class Operations: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_scenario_runs_cancel_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + run_id=run_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class ScenarioConfigurationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`operations` attribute. + :attr:`scenario_configurations` 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") @@ -75,18 +8740,602 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """List the operations for the provider. + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def get( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> _models.ScenarioConfiguration: + """Get a scenario definition. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Operation] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: ScenarioConfiguration. The ScenarioConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.chaos.models.ScenarioConfiguration + :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.ScenarioConfiguration] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_get_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ScenarioConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _create_or_update_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: Union[_models.ScenarioConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_scenario_configurations_create_or_update_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: _models.ScenarioConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.chaos.models.ScenarioConfiguration + :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 ScenarioConfiguration. The ScenarioConfiguration + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 ScenarioConfiguration. The ScenarioConfiguration + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ScenarioConfiguration. The ScenarioConfiguration + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + resource: Union[_models.ScenarioConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ScenarioConfiguration]: + """Create or update a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param resource: Resource create parameters. Is one of the following types: + ScenarioConfiguration, JSON, IO[bytes] Required. + :type resource: ~azure.mgmt.chaos.models.ScenarioConfiguration or JSON or IO[bytes] + :return: An instance of LROPoller that returns ScenarioConfiguration. The ScenarioConfiguration + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.ScenarioConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScenarioConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ScenarioConfiguration, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ScenarioConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ScenarioConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _delete_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_delete_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_delete( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a scenario definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "accept", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def list_all( + self, resource_group_name: str, workspace_name: str, scenario_name: str, **kwargs: Any + ) -> ItemPaged["_models.ScenarioConfiguration"]: + """Get a list of scenario definitions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :return: An iterator like instance of ScenarioConfiguration + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ScenarioConfiguration] :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.ScenarioConfiguration]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -99,12 +9348,21 @@ def list_all(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_all_request( - api_version=api_version, + _request = build_scenario_configurations_list_all_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_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) else: # make call to next link with the client's api-version @@ -119,16 +9377,24 @@ def prepare_request(next_link=None): _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" + 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.ScenarioConfiguration], + 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) @@ -141,9 +9407,577 @@ 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def execute( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> None: + """Execute the scenario execution with the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_execute_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _validate_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_scenario_configurations_validate_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + 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 + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_validate( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + **kwargs: Any + ) -> LROPoller[_models.Validation]: + """Validate the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :return: An instance of LROPoller that returns Validation. The Validation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.Validation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Validation] = 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._validate_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Validation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Validation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Validation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def _fix_resource_permissions_initial( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[Union[_models.FixResourcePermissionsRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_scenario_configurations_fix_resource_permissions_request( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[_models.FixResourcePermissionsRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.chaos.models.FixResourcePermissionsRequest + :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 PermissionsFix. The PermissionsFix is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: 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 PermissionsFix. The PermissionsFix is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PermissionsFix. The PermissionsFix is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-05-01-preview", + params_added_on={ + "2026-05-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "workspace_name", + "scenario_name", + "scenario_configuration_name", + "content_type", + ] + }, + api_versions_list=["2026-05-01-preview"], + ) + def begin_fix_resource_permissions( + self, + resource_group_name: str, + workspace_name: str, + scenario_name: str, + scenario_configuration_name: str, + body: Optional[Union[_models.FixResourcePermissionsRequest, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.PermissionsFix]: + """Fixes resource permissions for the given scenario configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: String that represents a Workspace resource name. Required. + :type workspace_name: str + :param scenario_name: Name of the scenario. Required. + :type scenario_name: str + :param scenario_configuration_name: Name of the scenario definition. Required. + :type scenario_configuration_name: str + :param body: Is one of the following types: FixResourcePermissionsRequest, JSON, IO[bytes] + Default value is None. + :type body: ~azure.mgmt.chaos.models.FixResourcePermissionsRequest or JSON or IO[bytes] + :return: An instance of LROPoller that returns PermissionsFix. The PermissionsFix is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PermissionsFix] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.PermissionsFix] = 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._fix_resource_permissions_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + scenario_name=scenario_name, + scenario_configuration_name=scenario_configuration_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.PermissionsFix, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PermissionsFix].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PermissionsFix]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_patch.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_patch.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py deleted file mode 100644 index 6db9612e53dd..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py +++ /dev/null @@ -1,257 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - location: str, subscription_id: str, *, continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(location: str, target_type_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "location": _SERIALIZER.url("location", location, "str", min_length=1), - "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TargetTypesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`target_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: ChaosManagementClientConfiguration = 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, location: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.TargetType"]: - """Get a list of Target Type resources for given location. - - :param location: The name of the Azure region. Required. - :type location: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either TargetType or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.TargetType] - :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.TargetTypeListResult] = 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_list_request( - location=location, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - 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("TargetTypeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, location: str, target_type_name: str, **kwargs: Any) -> _models.TargetType: - """Get a Target Type resources for given location. - - :param location: The name of the Azure region. Required. - :type location: str - :param target_type_name: String that represents a Target Type resource name. Required. - :type target_type_name: str - :return: TargetType or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.TargetType - :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.TargetType] = kwargs.pop("cls", None) - - _request = build_get_request( - location=location, - target_type_name=target_type_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TargetType", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py deleted file mode 100644 index cc7990f7ad38..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import ChaosManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - subscription_id: str, - *, - continuation_token_parameter: 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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_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-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_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-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}", - ) - 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 - ), - "parentProviderNamespace": _SERIALIZER.url( - "parent_provider_namespace", - parent_provider_namespace, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceType": _SERIALIZER.url( - "parent_resource_type", - parent_resource_type, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "parentResourceName": _SERIALIZER.url( - "parent_resource_name", - parent_resource_name, - "str", - max_length=63, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class TargetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.chaos.ChaosManagementClient`'s - :attr:`targets` 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: ChaosManagementClientConfiguration = 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_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - continuation_token_parameter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.Target"]: - """Get a list of Target resources that extend a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param continuation_token_parameter: String that sets the continuation token. Default value is - None. - :type continuation_token_parameter: str - :return: An iterator like instance of either Target or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.Target] - :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.TargetListResult] = 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_list_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - subscription_id=self._config.subscription_id, - continuation_token_parameter=continuation_token_parameter, - 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("TargetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - **kwargs: Any - ) -> _models.Target: - """Get a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :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.Target] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Target", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: _models.Target, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Required. - :type resource: ~azure.mgmt.chaos.models.Target - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Required. - :type resource: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - resource: Union[_models.Target, IO[bytes]], - **kwargs: Any - ) -> _models.Target: - """Create or update a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :param resource: Target resource to be created or updated. Is either a Target type or a - IO[bytes] type. Required. - :type resource: ~azure.mgmt.chaos.models.Target or IO[bytes] - :return: Target or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.Target - :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 {}) - - 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.Target] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(resource, (IOBase, bytes)): - _content = resource - else: - _json = self._serialize.body(resource, "Target") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Target", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - parent_provider_namespace: str, - parent_resource_type: str, - parent_resource_name: str, - target_name: str, - **kwargs: Any - ) -> None: - """Delete a Target resource that extends a tracked regional resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parent_provider_namespace: The parent resource provider namespace. Required. - :type parent_provider_namespace: str - :param parent_resource_type: The parent resource type. Required. - :type parent_resource_type: str - :param parent_resource_name: The parent resource name. Required. - :type parent_resource_name: str - :param target_name: String that represents a Target resource name. Required. - :type target_name: str - :return: None or the result of cls(response) - :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 = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - parent_provider_namespace=parent_provider_namespace, - parent_resource_type=parent_resource_type, - parent_resource_name=parent_resource_name, - target_name=target_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_get.py new file mode 100644 index 000000000000..d6f2e9e64e5f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python action_versions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.action_versions.get( + location="westus2", + action_name="microsoft-compute-shutdown", + version_name="1.0", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ActionVersions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_list.py new file mode 100644 index 000000000000..62ade65c85c7 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/action_versions_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python action_versions_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.action_versions.list( + location="westus2", + action_name="microsoft-compute-shutdown", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/ActionVersions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_get.py new file mode 100644 index 000000000000..054b9fe78b58 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python actions_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.actions.get( + location="westus2", + action_name="microsoft-compute-shutdown", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Actions_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_list.py new file mode 100644 index 000000000000..9e9451c84264 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/actions_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python actions_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.actions.list( + location="westus2", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/Actions_List.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_create_or_update.py index 8f423f89a98c..1300b904bce1 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_create_or_update.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_create_or_update.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities.create_or_update( @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Capabilities_CreateOrUpdate.json +# x-ms-original-file: 2026-05-01-preview/Capabilities_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_delete.py index c024de62fea2..168f7b26b5a2 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_delete.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_delete.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) client.capabilities.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Capabilities_Delete.json +# x-ms-original-file: 2026-05-01-preview/Capabilities_Delete.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_get.py index 21ba6a515804..4921422922c7 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_get.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities.get( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Capabilities_Get.json +# x-ms-original-file: 2026-05-01-preview/Capabilities_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_list.py index c143a4fd7740..4b9c52f7bb37 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capabilities_list.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities.list( @@ -42,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Capabilities_List.json +# x-ms-original-file: 2026-05-01-preview/Capabilities_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_get.py index 942732e45889..2b6e686610a8 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_get.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.capability_types.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/CapabilityTypes_Get.json +# x-ms-original-file: 2026-05-01-preview/CapabilityTypes_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_list.py index ace6d07fea69..9d28e3738128 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/capability_types_list.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.capability_types.list( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/CapabilityTypes_List.json +# x-ms-original-file: 2026-05-01-preview/CapabilityTypes_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_get.py new file mode 100644 index 000000000000..378fc13ed79e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python discovered_resources_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.discovered_resources.get( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + discovered_resource_name="a1b2c3d4-e5f6-7890-abcd-ef1234567890", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/DiscoveredResources_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_list_by_workspace.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_list_by_workspace.py new file mode 100644 index 000000000000..f1e5e93daafc --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/discovered_resources_list_by_workspace.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python discovered_resources_list_by_workspace.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.discovered_resources.list_by_workspace( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/DiscoveredResources_ListByWorkspace.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_cancel.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_cancel.py index f01772227479..2e560e6eeb8a 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_cancel.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_cancel.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) client.experiments.begin_cancel( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_Cancel.json +# x-ms-original-file: 2026-05-01-preview/Experiments_Cancel.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_create_or_update.py index db442584f3f1..f2d3a69cfeaf 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_create_or_update.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_create_or_update.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.begin_create_or_update( @@ -38,6 +38,10 @@ def main(): "identity": {"type": "SystemAssigned"}, "location": "eastus2euap", "properties": { + "customerDataStorage": { + "blobContainerName": "azurechaosstudioexperiments", + "storageAccountResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleRG/providers/Microsoft.Storage/storageAccounts/exampleStorage", + }, "selectors": [ { "id": "selector1", @@ -76,6 +80,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_CreateOrUpdate.json +# x-ms-original-file: 2026-05-01-preview/Experiments_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_delete.py index 09f7cfae84aa..7d562609bc06 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_delete.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_delete.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) client.experiments.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_Delete.json +# x-ms-original-file: 2026-05-01-preview/Experiments_Delete.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_execution_details.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_execution_details.py index f46afa49a1cc..08783089ba31 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_execution_details.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_execution_details.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.execution_details( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_ExecutionDetails.json +# x-ms-original-file: 2026-05-01-preview/Experiments_ExecutionDetails.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get.py index 8eef85bc8a18..1fdaab7c77ec 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_Get.json +# x-ms-original-file: 2026-05-01-preview/Experiments_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get_execution.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get_execution.py index fad90d87a7e1..baa7365864e7 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get_execution.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_get_execution.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.get_execution( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_GetExecution.json +# x-ms-original-file: 2026-05-01-preview/Experiments_GetExecution.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list.py index 939f6fbef937..297eb517625b 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_List.json +# x-ms-original-file: 2026-05-01-preview/Experiments_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all.py index b0b170e5e00e..c25edb72d12f 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.list_all() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_ListAll.json +# x-ms-original-file: 2026-05-01-preview/Experiments_ListAll.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all_executions.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all_executions.py index 73837a7d942a..221e549a4caf 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all_executions.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_list_all_executions.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.list_all_executions( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_ListAllExecutions.json +# x-ms-original-file: 2026-05-01-preview/Experiments_ListAllExecutions.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_start.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_start.py index 136fc7635085..e68730dd50d2 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_start.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_start.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) client.experiments.begin_start( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_Start.json +# x-ms-original-file: 2026-05-01-preview/Experiments_Start.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_update.py index 96a848ed4bce..d0c36eb08a0f 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_update.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/experiments_update.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.experiments.begin_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Experiments_Update.json +# x-ms-original-file: 2026-05-01-preview/Experiments_Update.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/operation_statuses_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/operation_statuses_get.py index 4cc1e87199dd..8f1fc1a78f17 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/operation_statuses_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/operation_statuses_get.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="e25c0d12-0335-4fec-8ef8-3b4f9a10649e", + subscription_id="SUBSCRIPTION_ID", ) response = client.operation_statuses.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/OperationStatuses_Get.json +# x-ms-original-file: 2026-05-01-preview/OperationStatuses_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/operations_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/operations_list.py index e08f6e17687c..6e6c028cb614 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/operations_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/operations_list.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(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Operations_List.json +# x-ms-original-file: 2026-05-01-preview/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource.py new file mode 100644 index 000000000000..efaa666db71b --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_create_or_update_create_or_update_a_private_access_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.begin_create_or_update( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + resource={"location": "centraluseuap", "properties": {}}, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_CreateOrUpdate_Create_Or_Update_A_Private_Access_Resource.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource_with_public_network_access.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource_with_public_network_access.py new file mode 100644 index 000000000000..83a49c180eb9 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_create_or_update_create_or_update_a_private_access_resource_with_public_network_access.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_create_or_update_create_or_update_a_private_access_resource_with_public_network_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.begin_create_or_update( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + resource={"location": "centraluseuap", "properties": {"publicNetworkAccess": "Enabled"}}, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_CreateOrUpdate_Create_Or_Update_A_Private_Access_Resource_With_Public_Network_Access.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete.py new file mode 100644 index 000000000000..56696c34725b --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.private_accesses.begin_delete( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ).result() + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete_aprivate_endpoint_connection.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete_aprivate_endpoint_connection.py new file mode 100644 index 000000000000..2e32397542a9 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_delete_aprivate_endpoint_connection.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_delete_aprivate_endpoint_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.private_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_endpoint_connection_name="myPrivateEndpointConnection", + ).result() + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_DeleteAPrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_aprivate_endpoint_connection.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_aprivate_endpoint_connection.py new file mode 100644 index 000000000000..1845873bb2d1 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_aprivate_endpoint_connection.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_get_aprivate_endpoint_connection.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.get_a_private_endpoint_connection( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_endpoint_connection_name="myPrivateEndpointConnection", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_GetAPrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource.py new file mode 100644 index 000000000000..e0b187690f93 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_get_get_a_private_access_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.get( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_Get_Get_A_Private_Access_Resource.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource_with_private_endpoint.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource_with_private_endpoint.py new file mode 100644 index 000000000000..6b3dd1f8f3cd --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_get_a_private_access_resource_with_private_endpoint.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_get_get_a_private_access_resource_with_private_endpoint.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.get( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_Get_Get_A_Private_Access_Resource_With_Private_Endpoint.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_private_link_resources.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_private_link_resources.py new file mode 100644 index 000000000000..f93b5b4b78b2 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_get_private_link_resources.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_get_private_link_resources.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.get_private_link_resources( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_GetPrivateLinkResources.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list.py new file mode 100644 index 000000000000..8eb5152aceb1 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.list( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_List.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_all.py new file mode 100644 index 000000000000..1a0576283958 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_all.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_list_all.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.list_all() + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_ListAll.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_private_endpoint_connections.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_private_endpoint_connections.py new file mode 100644 index 000000000000..ad21e20375c7 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_list_private_endpoint_connections.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_list_private_endpoint_connections.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.list_private_endpoint_connections( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_ListPrivateEndpointConnections.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_update.py new file mode 100644 index 000000000000..432adea345af --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_accesses_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_accesses_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.private_accesses.begin_update( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + properties={"tags": {"tag1": "value1", "tag2": "value2"}}, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/PrivateAccesses_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update.py new file mode 100644 index 000000000000..035995973b53 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update.py @@ -0,0 +1,65 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.begin_create_or_update( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + resource={ + "properties": { + "exclusions": { + "resources": [ + "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/protectedVM" + ], + "tags": [{"key": "environment", "value": "production"}], + "types": ["Microsoft.Compute/virtualMachineScaleSets"], + }, + "filters": {"locations": ["eastus"], "zones": ["1"]}, + "parameters": [ + {"key": "duration", "value": "PT10M"}, + { + "key": "targetResourceIds", + "value": '["/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/vm1","/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/vm2"]', + }, + ], + "scenarioId": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/workspaces/exampleWorkspace/scenarios/12345678-1234-1234-1234-123456789012", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update_with_physical_zones.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update_with_physical_zones.py new file mode 100644 index 000000000000..414f4edb2a1d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_create_or_update_with_physical_zones.py @@ -0,0 +1,57 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_create_or_update_with_physical_zones.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.begin_create_or_update( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-physical-zone", + resource={ + "properties": { + "exclusions": { + "resources": [ + "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/protectedVM" + ] + }, + "filters": {"locations": ["westus2"], "physicalZones": ["westus2-az1"]}, + "parameters": [{"key": "duration", "value": "PT10M"}], + "scenarioId": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/workspaces/exampleWorkspace/scenarios/12345678-1234-1234-1234-123456789012", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_CreateOrUpdate_With_Physical_Zones.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_delete.py new file mode 100644 index 000000000000..f93f1bcf4419 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scenario_configurations.begin_delete( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + ).result() + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_execute.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_execute.py new file mode 100644 index 000000000000..51eab993185b --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_execute.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_execute.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scenario_configurations.execute( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + ) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_Execute.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_fix_resource_permissions.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_fix_resource_permissions.py new file mode 100644 index 000000000000..e0f0dc82e0a0 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_fix_resource_permissions.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_fix_resource_permissions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.begin_fix_resource_permissions( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_FixResourcePermissions.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_get.py new file mode 100644 index 000000000000..7a7e815d57aa --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.get( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_list_all.py new file mode 100644 index 000000000000..2a27c72e72ad --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_list_all.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_list_all.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.list_all( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_ListAll.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_validate.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_validate.py new file mode 100644 index 000000000000..02df12e8465d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_configurations_validate.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_configurations_validate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_configurations.begin_validate( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + scenario_configuration_name="config-5678-9012-3456-789012345678", + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioConfigurations_Validate.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_cancel.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_cancel.py new file mode 100644 index 000000000000..b1c94d1f9d1c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_cancel.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_runs_cancel.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scenario_runs.cancel( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + run_id="abcd1234-5678-9012-3456-789012345678", + ) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioRuns_Cancel.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_get.py new file mode 100644 index 000000000000..777976aea12d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_runs_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_runs.get( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + run_id="abcd1234-5678-9012-3456-789012345678", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioRuns_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_list_all.py new file mode 100644 index 000000000000..105c3b6dccbf --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenario_runs_list_all.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenario_runs_list_all.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenario_runs.list_all( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="12345678-1234-1234-1234-123456789012", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/ScenarioRuns_ListAll.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_create_or_update.py new file mode 100644 index 000000000000..1821f16ed67a --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_create_or_update.py @@ -0,0 +1,106 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenarios_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenarios.create_or_update( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="zoneDownScenario", + resource={ + "properties": { + "actions": [ + { + "actionId": "urn:csci:microsoft:compute:shutdown/1.0.0", + "description": "Force shutdown VMSS instances in target zone", + "duration": "%%{parameters.duration}%%", + "name": "vmssZoneDown", + "parameters": [{"key": "zones", "value": "%%{filters.zones}%%"}], + }, + { + "actionId": "urn:csci:microsoft:compute:shutdown/1.0.0", + "description": "Force shutdown VM instances in target zone", + "duration": "%%{parameters.duration}%%", + "name": "vmZoneDown", + "parameters": [{"key": "zones", "value": "%%{filters.zones}%%"}], + }, + { + "actionId": "urn:csci:microsoft:azureClusteredCacheForRedis:Reboot/1.0.0", + "description": "Force failover of Redis instances to simulate backend zonal outage", + "duration": "PT5M", + "name": "redisFailover", + "parameters": [{"key": "RebootType", "value": "PrimaryNode"}], + }, + { + "actionId": "urn:csci:microsoft:Automation:StartRunbook/1.0.0", + "description": "Custom Runbook 1", + "duration": "PT30M", + "externalResource": { + "resourceId": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Automation/automationAccounts/exampleAutomationAccount/runbooks/exampleRunbook" + }, + "name": "custom-runbook-1", + "parameters": [ + {"key": "RunbookParameters", "value": "%%{parameters.customRunbook1ParametersJson}%%"} + ], + }, + ], + "description": "Induces an outage of all discovered VM and VMSS instances in the target zone with an option to invoke custom scripted actions using Automation Runbooks. Additionally, it forces failover of discovered Redis instances to simulate backend zonal outage.", + "parameters": [ + { + "default": "PT15M", + "description": "The duration of the outage scenario.", + "name": "duration", + "required": False, + "type": "string", + }, + { + "description": "Optional custom runbook 1 resource ID. If not provided, this action will be skipped.", + "name": "customRunbook1ResourceId", + "required": False, + "type": "string", + }, + { + "default": "{}", + "description": "Optional custom runbook 1 parameters in JSON format.", + "name": "customRunbook1ParametersJson", + "required": False, + "type": "string", + }, + ], + } + }, + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Scenarios_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_delete.py new file mode 100644 index 000000000000..59ba4a0fc9d0 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenarios_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scenarios.delete( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="myVMShutdownScenario", + ) + + +# x-ms-original-file: 2026-05-01-preview/Scenarios_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_get.py new file mode 100644 index 000000000000..8b613b4da4e7 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenarios_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenarios.get( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + scenario_name="zoneDownScenario", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Scenarios_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_list_all.py new file mode 100644 index 000000000000..5b7c0540145e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/scenarios_list_all.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python scenarios_list_all.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scenarios.list_all( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/Scenarios_ListAll.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_get.py index 5e42caa92ae6..5a7402d07810 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_get.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.target_types.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/TargetTypes_Get.json +# x-ms-original-file: 2026-05-01-preview/TargetTypes_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_list.py index b605038ac671..283b6e550afb 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/target_types_list.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.target_types.list( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/TargetTypes_List.json +# x-ms-original-file: 2026-05-01-preview/TargetTypes_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_create_or_update.py index bc39603d8c12..0a021cfa21cd 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_create_or_update.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_create_or_update.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.targets.create_or_update( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Targets_CreateOrUpdate.json +# x-ms-original-file: 2026-05-01-preview/Targets_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_delete.py index 0502981a4ed5..86c4d1dfab65 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_delete.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_delete.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 = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) client.targets.delete( @@ -40,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Targets_Delete.json +# x-ms-original-file: 2026-05-01-preview/Targets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_get.py index 0a7f6b1d9594..13e40b478aac 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_get.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_get.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. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.targets.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Targets_Get.json +# x-ms-original-file: 2026-05-01-preview/Targets_Get.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_list.py index 75f5ea143776..d2dd5b18f87f 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_list.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/targets_list.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. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ChaosManagementClient( credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + subscription_id="SUBSCRIPTION_ID", ) response = client.targets.list( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2025-01-01/examples/Targets_List.json +# x-ms-original-file: 2026-05-01-preview/Targets_List.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_create_or_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_create_or_update.py new file mode 100644 index 000000000000..2e72b33d8d52 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_create_or_update.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.begin_create_or_update( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + resource={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleIdentity": {} + }, + }, + "location": "westus2", + "properties": { + "scopes": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup"] + }, + "tags": {"department": "engineering", "environment": "production", "project": "chaos-testing"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_delete.py new file mode 100644 index 000000000000..5eb610332121 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.workspaces.begin_delete( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + ).result() + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_get.py new file mode 100644 index 000000000000..f84ce327848c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.get( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + ) + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list.py new file mode 100644 index 000000000000..03c6fbe9e930 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.list( + resource_group_name="exampleRG", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_List.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list_all.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list_all.py new file mode 100644 index 000000000000..e2f87aa8fa92 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_list_all.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_list_all.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.list_all() + for item in response: + print(item) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_ListAll.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_refresh_recommendations.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_refresh_recommendations.py new file mode 100644 index 000000000000..be83e4bc45fc --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_refresh_recommendations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_refresh_recommendations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.begin_refresh_recommendations( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_RefreshRecommendations.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_update.py new file mode 100644 index 000000000000..da22c382b9cc --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/workspaces_update.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python workspaces_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.workspaces.begin_update( + resource_group_name="exampleRG", + workspace_name="exampleWorkspace", + properties={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleIdentity": {} + }, + }, + "tags": {"department": "engineering", "environment": "production", "project": "chaos-testing"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2026-05-01-preview/Workspaces_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/conftest.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/conftest.py index 868cc7c5163c..b916d7d5cfca 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/conftest.py +++ b/sdk/chaos/azure-mgmt-chaos/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/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations.py new file mode 100644 index 000000000000..e1147732b55a --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementActionVersionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_versions_get(self, resource_group): + response = self.client.action_versions.get( + location="str", + action_name="str", + version_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_versions_list(self, resource_group): + response = self.client.action_versions.list( + location="str", + action_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations_async.py new file mode 100644 index 000000000000..d3afcb9b5c4e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_action_versions_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementActionVersionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_versions_get(self, resource_group): + response = await self.client.action_versions.get( + location="str", + action_name="str", + version_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_versions_list(self, resource_group): + response = self.client.action_versions.list( + location="str", + action_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations.py new file mode 100644 index 000000000000..a220ca840869 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementActionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_actions_get(self, resource_group): + response = self.client.actions.get( + location="str", + action_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_actions_list(self, resource_group): + response = self.client.actions.list( + location="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations_async.py new file mode 100644 index 000000000000..8e4950e3af7e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_actions_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementActionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_actions_get(self, resource_group): + response = await self.client.actions.get( + location="str", + action_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_actions_list(self, resource_group): + response = self.client.actions.list( + location="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations.py index ddea4ee7a49f..10d39df8067d 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_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,21 +18,6 @@ class TestChaosManagementCapabilitiesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_capabilities_list(self, resource_group): - response = self.client.capabilities.list( - resource_group_name=resource_group.name, - parent_provider_namespace="str", - parent_resource_type="str", - parent_resource_name="str", - target_name="str", - api_version="2025-01-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_capabilities_get(self, resource_group): @@ -43,7 +28,6 @@ def test_capabilities_get(self, resource_group): parent_resource_name="str", target_name="str", capability_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -60,11 +44,16 @@ def test_capabilities_create_or_update(self, resource_group): target_name="str", capability_name="str", resource={ - "description": "str", "id": "str", "name": "str", - "parametersSchema": "str", - "publisher": "str", + "properties": { + "description": "str", + "parametersSchema": "str", + "provisioningState": "str", + "publisher": "str", + "targetType": "str", + "urn": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -73,11 +62,8 @@ def test_capabilities_create_or_update(self, resource_group): "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "targetType": "str", "type": "str", - "urn": "str", }, - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -93,8 +79,21 @@ def test_capabilities_delete(self, resource_group): parent_resource_name="str", target_name="str", capability_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_capabilities_list(self, resource_group): + response = self.client.capabilities.list( + resource_group_name=resource_group.name, + parent_provider_namespace="str", + parent_resource_type="str", + parent_resource_name="str", + target_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations_async.py index 15405e7ab1ff..02b5b0b38084 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capabilities_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,21 +19,6 @@ class TestChaosManagementCapabilitiesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_capabilities_list(self, resource_group): - response = self.client.capabilities.list( - resource_group_name=resource_group.name, - parent_provider_namespace="str", - parent_resource_type="str", - parent_resource_name="str", - target_name="str", - api_version="2025-01-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_capabilities_get(self, resource_group): @@ -44,7 +29,6 @@ async def test_capabilities_get(self, resource_group): parent_resource_name="str", target_name="str", capability_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -61,11 +45,16 @@ async def test_capabilities_create_or_update(self, resource_group): target_name="str", capability_name="str", resource={ - "description": "str", "id": "str", "name": "str", - "parametersSchema": "str", - "publisher": "str", + "properties": { + "description": "str", + "parametersSchema": "str", + "provisioningState": "str", + "publisher": "str", + "targetType": "str", + "urn": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -74,11 +63,8 @@ async def test_capabilities_create_or_update(self, resource_group): "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "targetType": "str", "type": "str", - "urn": "str", }, - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -94,8 +80,21 @@ async def test_capabilities_delete(self, resource_group): parent_resource_name="str", target_name="str", capability_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_capabilities_list(self, resource_group): + response = self.client.capabilities.list( + resource_group_name=resource_group.name, + parent_provider_namespace="str", + parent_resource_type="str", + parent_resource_name="str", + target_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations.py index 1527bcae0eee..3b23b8c04cd9 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_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 @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_capability_types_list(self, resource_group): - response = self.client.capability_types.list( + def test_capability_types_get(self, resource_group): + response = self.client.capability_types.get( location="str", target_type_name="str", - api_version="2025-01-01", + capability_type_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_capability_types_get(self, resource_group): - response = self.client.capability_types.get( + def test_capability_types_list(self, resource_group): + response = self.client.capability_types.list( location="str", target_type_name="str", - capability_type_name="str", - api_version="2025-01-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations_async.py index 7f0444eafec7..f9f5f017d92c 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_types_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_capability_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 @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_capability_types_list(self, resource_group): - response = self.client.capability_types.list( + async def test_capability_types_get(self, resource_group): + response = await self.client.capability_types.get( location="str", target_type_name="str", - api_version="2025-01-01", + capability_type_name="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_capability_types_get(self, resource_group): - response = await self.client.capability_types.get( + async def test_capability_types_list(self, resource_group): + response = self.client.capability_types.list( location="str", target_type_name="str", - capability_type_name="str", - api_version="2025-01-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations.py new file mode 100644 index 000000000000..dd251c6217d5 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementDiscoveredResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_discovered_resources_get(self, resource_group): + response = self.client.discovered_resources.get( + resource_group_name=resource_group.name, + workspace_name="str", + discovered_resource_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_discovered_resources_list_by_workspace(self, resource_group): + response = self.client.discovered_resources.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations_async.py new file mode 100644 index 000000000000..72596b00ca20 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_discovered_resources_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementDiscoveredResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_discovered_resources_get(self, resource_group): + response = await self.client.discovered_resources.get( + resource_group_name=resource_group.name, + workspace_name="str", + discovered_resource_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_discovered_resources_list_by_workspace(self, resource_group): + response = self.client.discovered_resources.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations.py index 662357eb3358..c7b863829adb 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_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,34 +18,12 @@ class TestChaosManagementExperimentsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_experiments_list_all(self, resource_group): - response = self.client.experiments.list_all( - api_version="2025-01-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_experiments_list(self, resource_group): - response = self.client.experiments.list( - resource_group_name=resource_group.name, - api_version="2025-01-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_experiments_get(self, resource_group): response = self.client.experiments.get( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -59,8 +37,12 @@ def test_experiments_begin_create_or_update(self, resource_group): experiment_name="str", resource={ "location": "str", - "selectors": ["chaos_target_selector"], - "steps": [{"branches": [{"actions": ["chaos_experiment_action"], "name": "str"}], "name": "str"}], + "properties": { + "selectors": ["chaos_target_selector"], + "steps": [{"branches": [{"actions": ["chaos_experiment_action"], "name": "str"}], "name": "str"}], + "customerDataStorage": {"blobContainerName": "str", "storageAccountResourceId": "str"}, + "provisioningState": "str", + }, "id": "str", "identity": { "type": "str", @@ -69,7 +51,6 @@ def test_experiments_begin_create_or_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -81,7 +62,6 @@ def test_experiments_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-01-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -102,7 +82,6 @@ def test_experiments_begin_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-01-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -114,19 +93,35 @@ def test_experiments_begin_delete(self, resource_group): response = self.client.experiments.begin_delete( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-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_experiments_list(self, resource_group): + response = self.client.experiments.list( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_experiments_list_all(self, resource_group): + response = self.client.experiments.list_all() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_experiments_begin_cancel(self, resource_group): response = self.client.experiments.begin_cancel( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -134,13 +129,12 @@ def test_experiments_begin_cancel(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_experiments_list_all_executions(self, resource_group): - response = self.client.experiments.list_all_executions( + def test_experiments_begin_start(self, resource_group): + response = self.client.experiments.begin_start( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -151,7 +145,6 @@ def test_experiments_get_execution(self, resource_group): resource_group_name=resource_group.name, experiment_name="str", execution_id="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -159,25 +152,23 @@ def test_experiments_get_execution(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_experiments_execution_details(self, resource_group): - response = self.client.experiments.execution_details( + def test_experiments_list_all_executions(self, resource_group): + response = self.client.experiments.list_all_executions( resource_group_name=resource_group.name, experiment_name="str", - execution_id="str", - api_version="2025-01-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_experiments_begin_start(self, resource_group): - response = self.client.experiments.begin_start( + def test_experiments_execution_details(self, resource_group): + response = self.client.experiments.execution_details( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", - ).result() # call '.result()' to poll until service return final result + execution_id="str", + ) # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations_async.py index 25375adccd65..9199f840e1c2 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_experiments_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,34 +19,12 @@ class TestChaosManagementExperimentsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_experiments_list_all(self, resource_group): - response = self.client.experiments.list_all( - api_version="2025-01-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_experiments_list(self, resource_group): - response = self.client.experiments.list( - resource_group_name=resource_group.name, - api_version="2025-01-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_experiments_get(self, resource_group): response = await self.client.experiments.get( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -61,8 +39,14 @@ async def test_experiments_begin_create_or_update(self, resource_group): experiment_name="str", resource={ "location": "str", - "selectors": ["chaos_target_selector"], - "steps": [{"branches": [{"actions": ["chaos_experiment_action"], "name": "str"}], "name": "str"}], + "properties": { + "selectors": ["chaos_target_selector"], + "steps": [ + {"branches": [{"actions": ["chaos_experiment_action"], "name": "str"}], "name": "str"} + ], + "customerDataStorage": {"blobContainerName": "str", "storageAccountResourceId": "str"}, + "provisioningState": "str", + }, "id": "str", "identity": { "type": "str", @@ -71,7 +55,6 @@ async def test_experiments_begin_create_or_update(self, resource_group): "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, "name": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -83,7 +66,6 @@ async def test_experiments_begin_create_or_update(self, resource_group): "tags": {"str": "str"}, "type": "str", }, - api_version="2025-01-01", ) ).result() # call '.result()' to poll until service return final result @@ -106,7 +88,6 @@ async def test_experiments_begin_update(self, resource_group): }, "tags": {"str": "str"}, }, - api_version="2025-01-01", ) ).result() # call '.result()' to poll until service return final result @@ -120,13 +101,30 @@ async def test_experiments_begin_delete(self, resource_group): await self.client.experiments.begin_delete( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-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_experiments_list(self, resource_group): + response = self.client.experiments.list( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_experiments_list_all(self, resource_group): + response = self.client.experiments.list_all() + 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_experiments_begin_cancel(self, resource_group): @@ -134,7 +132,6 @@ async def test_experiments_begin_cancel(self, resource_group): await self.client.experiments.begin_cancel( resource_group_name=resource_group.name, experiment_name="str", - api_version="2025-01-01", ) ).result() # call '.result()' to poll until service return final result @@ -143,13 +140,14 @@ async def test_experiments_begin_cancel(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_experiments_list_all_executions(self, resource_group): - response = self.client.experiments.list_all_executions( - resource_group_name=resource_group.name, - experiment_name="str", - api_version="2025-01-01", - ) - result = [r async for r in response] + async def test_experiments_begin_start(self, resource_group): + response = await ( + await self.client.experiments.begin_start( + resource_group_name=resource_group.name, + experiment_name="str", + ) + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @@ -160,7 +158,6 @@ async def test_experiments_get_execution(self, resource_group): resource_group_name=resource_group.name, experiment_name="str", execution_id="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -168,27 +165,23 @@ async def test_experiments_get_execution(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_experiments_execution_details(self, resource_group): - response = await self.client.experiments.execution_details( + async def test_experiments_list_all_executions(self, resource_group): + response = self.client.experiments.list_all_executions( resource_group_name=resource_group.name, experiment_name="str", - execution_id="str", - api_version="2025-01-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_experiments_begin_start(self, resource_group): - response = await ( - await self.client.experiments.begin_start( - resource_group_name=resource_group.name, - experiment_name="str", - api_version="2025-01-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_experiments_execution_details(self, resource_group): + response = await self.client.experiments.execution_details( + resource_group_name=resource_group.name, + experiment_name="str", + execution_id="str", + ) # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations.py index ba59498d0469..f54f7524ce94 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_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 @@ -24,7 +24,6 @@ def test_operation_statuses_get(self, resource_group): response = self.client.operation_statuses.get( location="str", operation_id="str", - api_version="2025-01-01", ) # please add some check logic here by yourself diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations_async.py index 9284449e9197..b5a667d1b13a 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operation_statuses_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 @@ -25,7 +25,6 @@ async def test_operation_statuses_get(self, resource_group): response = await self.client.operation_statuses.get( location="str", operation_id="str", - api_version="2025-01-01", ) # please add some check logic here by yourself diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations.py index a87e106cf694..c7d64542c47e 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_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_all(self, resource_group): - response = self.client.operations.list_all( - api_version="2025-01-01", - ) + response = self.client.operations.list_all() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations_async.py index 355766401b97..bff4f941e513 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_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_all(self, resource_group): - response = self.client.operations.list_all( - api_version="2025-01-01", - ) + response = self.client.operations.list_all() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations.py new file mode 100644 index 000000000000..4156fded5a2e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations.py @@ -0,0 +1,172 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementPrivateAccessesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_get(self, resource_group): + response = self.client.private_accesses.get( + resource_group_name=resource_group.name, + private_access_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_begin_create_or_update(self, resource_group): + response = self.client.private_accesses.begin_create_or_update( + resource_group_name=resource_group.name, + private_access_name="str", + resource={ + "location": "str", + "properties": { + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "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", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_begin_update(self, resource_group): + response = self.client.private_accesses.begin_update( + resource_group_name=resource_group.name, + private_access_name="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_private_accesses_begin_delete(self, resource_group): + response = self.client.private_accesses.begin_delete( + resource_group_name=resource_group.name, + private_access_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_list(self, resource_group): + response = self.client.private_accesses.list( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_list_all(self, resource_group): + response = self.client.private_accesses.list_all() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_get_private_link_resources(self, resource_group): + response = self.client.private_accesses.get_private_link_resources( + resource_group_name=resource_group.name, + private_access_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_get_a_private_endpoint_connection(self, resource_group): + response = self.client.private_accesses.get_a_private_endpoint_connection( + resource_group_name=resource_group.name, + private_access_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_begin_delete_a_private_endpoint_connection(self, resource_group): + response = self.client.private_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name=resource_group.name, + private_access_name="str", + private_endpoint_connection_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_accesses_list_private_endpoint_connections(self, resource_group): + response = self.client.private_accesses.list_private_endpoint_connections( + resource_group_name=resource_group.name, + private_access_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations_async.py new file mode 100644 index 000000000000..2ad98e9c749f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_private_accesses_operations_async.py @@ -0,0 +1,181 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementPrivateAccessesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_get(self, resource_group): + response = await self.client.private_accesses.get( + resource_group_name=resource_group.name, + private_access_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_accesses.begin_create_or_update( + resource_group_name=resource_group.name, + private_access_name="str", + resource={ + "location": "str", + "properties": { + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "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", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_begin_update(self, resource_group): + response = await ( + await self.client.private_accesses.begin_update( + resource_group_name=resource_group.name, + private_access_name="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_private_accesses_begin_delete(self, resource_group): + response = await ( + await self.client.private_accesses.begin_delete( + resource_group_name=resource_group.name, + private_access_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_list(self, resource_group): + response = self.client.private_accesses.list( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_list_all(self, resource_group): + response = self.client.private_accesses.list_all() + 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_private_accesses_get_private_link_resources(self, resource_group): + response = await self.client.private_accesses.get_private_link_resources( + resource_group_name=resource_group.name, + private_access_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_get_a_private_endpoint_connection(self, resource_group): + response = await self.client.private_accesses.get_a_private_endpoint_connection( + resource_group_name=resource_group.name, + private_access_name="str", + private_endpoint_connection_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_begin_delete_a_private_endpoint_connection(self, resource_group): + response = await ( + await self.client.private_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name=resource_group.name, + private_access_name="str", + private_endpoint_connection_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_accesses_list_private_endpoint_connections(self, resource_group): + response = self.client.private_accesses.list_private_endpoint_connections( + resource_group_name=resource_group.name, + private_access_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations.py new file mode 100644 index 000000000000..99d272299ed8 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenarioConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_get(self, resource_group): + response = self.client.scenario_configurations.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_begin_create_or_update(self, resource_group): + response = self.client.scenario_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "scenarioId": "str", + "exclusions": {"resources": ["str"], "tags": [{"key": "str", "value": "str"}], "types": ["str"]}, + "filters": {"locations": ["str"], "physicalZones": ["str"], "zones": ["str"]}, + "parameters": [{"key": "str", "value": "str"}], + "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", + }, + "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_scenario_configurations_begin_delete(self, resource_group): + response = self.client.scenario_configurations.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_list_all(self, resource_group): + response = self.client.scenario_configurations.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_execute(self, resource_group): + response = self.client.scenario_configurations.execute( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_begin_validate(self, resource_group): + response = self.client.scenario_configurations.begin_validate( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_configurations_begin_fix_resource_permissions(self, resource_group): + response = self.client.scenario_configurations.begin_fix_resource_permissions( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations_async.py new file mode 100644 index 000000000000..ceb0794f9b66 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_configurations_operations_async.py @@ -0,0 +1,142 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenarioConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_configurations_get(self, resource_group): + response = await self.client.scenario_configurations.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_configurations_begin_create_or_update(self, resource_group): + response = await ( + await self.client.scenario_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "scenarioId": "str", + "exclusions": { + "resources": ["str"], + "tags": [{"key": "str", "value": "str"}], + "types": ["str"], + }, + "filters": {"locations": ["str"], "physicalZones": ["str"], "zones": ["str"]}, + "parameters": [{"key": "str", "value": "str"}], + "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", + }, + "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_scenario_configurations_begin_delete(self, resource_group): + response = await ( + await self.client.scenario_configurations.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_configurations_list_all(self, resource_group): + response = self.client.scenario_configurations.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="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_scenario_configurations_execute(self, resource_group): + response = await self.client.scenario_configurations.execute( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_configurations_begin_validate(self, resource_group): + response = await ( + await self.client.scenario_configurations.begin_validate( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_configurations_begin_fix_resource_permissions(self, resource_group): + response = await ( + await self.client.scenario_configurations.begin_fix_resource_permissions( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + scenario_configuration_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations.py new file mode 100644 index 000000000000..a5e908c91380 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenarioRunsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_runs_get(self, resource_group): + response = self.client.scenario_runs.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_runs_list_all(self, resource_group): + response = self.client.scenario_runs.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenario_runs_cancel(self, resource_group): + response = self.client.scenario_runs.cancel( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + run_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations_async.py new file mode 100644 index 000000000000..bdacf411d94c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenario_runs_operations_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenarioRunsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_runs_get(self, resource_group): + response = await self.client.scenario_runs.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenario_runs_list_all(self, resource_group): + response = self.client.scenario_runs.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="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_scenario_runs_cancel(self, resource_group): + response = await self.client.scenario_runs.cancel( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + run_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations.py new file mode 100644 index 000000000000..7c16f6294111 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenariosOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenarios_get(self, resource_group): + response = self.client.scenarios.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenarios_create_or_update(self, resource_group): + response = self.client.scenarios.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "actions": [ + { + "actionId": "str", + "duration": "str", + "name": "str", + "description": "str", + "externalResource": {"resourceId": "str"}, + "parameters": [{"key": "str", "value": "str"}], + "runAfter": { + "items": [{"name": "str", "type": "str", "onActionLifecycle": "str"}], + "behavior": "str", + }, + "timeout": "str", + "waitBefore": "str", + } + ], + "parameters": [ + {"name": "str", "type": "str", "default": "str", "description": "str", "required": bool} + ], + "createdFrom": "str", + "description": "str", + "provisioningState": "str", + "recommendation": {"recommendationStatus": "str", "evaluationRunAt": "2020-02-20 00:00:00"}, + "version": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenarios_delete(self, resource_group): + response = self.client.scenarios.delete( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scenarios_list_all(self, resource_group): + response = self.client.scenarios.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations_async.py new file mode 100644 index 000000000000..84167e526236 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_scenarios_operations_async.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementScenariosOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenarios_get(self, resource_group): + response = await self.client.scenarios.get( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenarios_create_or_update(self, resource_group): + response = await self.client.scenarios.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "actions": [ + { + "actionId": "str", + "duration": "str", + "name": "str", + "description": "str", + "externalResource": {"resourceId": "str"}, + "parameters": [{"key": "str", "value": "str"}], + "runAfter": { + "items": [{"name": "str", "type": "str", "onActionLifecycle": "str"}], + "behavior": "str", + }, + "timeout": "str", + "waitBefore": "str", + } + ], + "parameters": [ + {"name": "str", "type": "str", "default": "str", "description": "str", "required": bool} + ], + "createdFrom": "str", + "description": "str", + "provisioningState": "str", + "recommendation": {"recommendationStatus": "str", "evaluationRunAt": "2020-02-20 00:00:00"}, + "version": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenarios_delete(self, resource_group): + response = await self.client.scenarios.delete( + resource_group_name=resource_group.name, + workspace_name="str", + scenario_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scenarios_list_all(self, resource_group): + response = self.client.scenarios.list_all( + resource_group_name=resource_group.name, + workspace_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations.py index ae4f8fb6dba9..5c98ec4dd37a 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_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 @@ -20,23 +20,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_target_types_list(self, resource_group): - response = self.client.target_types.list( + def test_target_types_get(self, resource_group): + response = self.client.target_types.get( location="str", - api_version="2025-01-01", + target_type_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_target_types_get(self, resource_group): - response = self.client.target_types.get( + def test_target_types_list(self, resource_group): + response = self.client.target_types.list( location="str", - target_type_name="str", - api_version="2025-01-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations_async.py index 398534966937..aa2d681d0325 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_types_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_target_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 @@ -21,23 +21,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_target_types_list(self, resource_group): - response = self.client.target_types.list( + async def test_target_types_get(self, resource_group): + response = await self.client.target_types.get( location="str", - api_version="2025-01-01", + target_type_name="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_target_types_get(self, resource_group): - response = await self.client.target_types.get( + async def test_target_types_list(self, resource_group): + response = self.client.target_types.list( location="str", - target_type_name="str", - api_version="2025-01-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations.py index f717a4e237ea..1b11e6192ada 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_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,20 +18,6 @@ class TestChaosManagementTargetsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_targets_list(self, resource_group): - response = self.client.targets.list( - resource_group_name=resource_group.name, - parent_provider_namespace="str", - parent_resource_type="str", - parent_resource_name="str", - api_version="2025-01-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_targets_get(self, resource_group): @@ -41,7 +27,6 @@ def test_targets_get(self, resource_group): parent_resource_type="str", parent_resource_name="str", target_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -71,7 +56,6 @@ def test_targets_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -86,8 +70,20 @@ def test_targets_delete(self, resource_group): parent_resource_type="str", parent_resource_name="str", target_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_targets_list(self, resource_group): + response = self.client.targets.list( + resource_group_name=resource_group.name, + parent_provider_namespace="str", + parent_resource_type="str", + parent_resource_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations_async.py index 9d1b0764ef8b..ca487c695b7b 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_operations_async.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_targets_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,20 +19,6 @@ class TestChaosManagementTargetsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_targets_list(self, resource_group): - response = self.client.targets.list( - resource_group_name=resource_group.name, - parent_provider_namespace="str", - parent_resource_type="str", - parent_resource_name="str", - api_version="2025-01-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_targets_get(self, resource_group): @@ -42,7 +28,6 @@ async def test_targets_get(self, resource_group): parent_resource_type="str", parent_resource_name="str", target_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -72,7 +57,6 @@ async def test_targets_create_or_update(self, resource_group): }, "type": "str", }, - api_version="2025-01-01", ) # please add some check logic here by yourself @@ -87,8 +71,20 @@ async def test_targets_delete(self, resource_group): parent_resource_type="str", parent_resource_name="str", target_name="str", - api_version="2025-01-01", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_targets_list(self, resource_group): + response = self.client.targets.list( + resource_group_name=resource_group.name, + parent_provider_namespace="str", + parent_resource_type="str", + parent_resource_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations.py new file mode 100644 index 000000000000..7760d976eff2 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementWorkspacesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_get(self, resource_group): + response = self.client.workspaces.get( + resource_group_name=resource_group.name, + workspace_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_begin_create_or_update(self, resource_group): + response = self.client.workspaces.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + resource={ + "location": "str", + "properties": {"scopes": ["str"], "communicationEndpoint": "str", "provisioningState": "str"}, + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_begin_update(self, resource_group): + response = self.client.workspaces.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "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_workspaces_begin_delete(self, resource_group): + response = self.client.workspaces.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_list(self, resource_group): + response = self.client.workspaces.list( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_list_all(self, resource_group): + response = self.client.workspaces.list_all() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_begin_refresh_recommendations(self, resource_group): + response = self.client.workspaces.begin_refresh_recommendations( + resource_group_name=resource_group.name, + workspace_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations_async.py b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations_async.py new file mode 100644 index 000000000000..5ece17636bf9 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_tests/test_chaos_management_workspaces_operations_async.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.chaos.aio import ChaosManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestChaosManagementWorkspacesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ChaosManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_get(self, resource_group): + response = await self.client.workspaces.get( + resource_group_name=resource_group.name, + workspace_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspaces.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + resource={ + "location": "str", + "properties": {"scopes": ["str"], "communicationEndpoint": "str", "provisioningState": "str"}, + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "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", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_begin_update(self, resource_group): + response = await ( + await self.client.workspaces.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + properties={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "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_workspaces_begin_delete(self, resource_group): + response = await ( + await self.client.workspaces.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_list(self, resource_group): + response = self.client.workspaces.list( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_list_all(self, resource_group): + response = self.client.workspaces.list_all() + 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_workspaces_begin_refresh_recommendations(self, resource_group): + response = await ( + await self.client.workspaces.begin_refresh_recommendations( + resource_group_name=resource_group.name, + workspace_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/chaos/azure-mgmt-chaos/pyproject.toml b/sdk/chaos/azure-mgmt-chaos/pyproject.toml index 540da07d41af..fd3f7f2a784b 100644 --- a/sdk/chaos/azure-mgmt-chaos/pyproject.toml +++ b/sdk/chaos/azure-mgmt-chaos/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-chaos" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Chaos Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.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" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.chaos._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-chaos" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Chaos Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +title = "ChaosManagementClient" +sample_link = "" +exclude_folders = "" diff --git a/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml b/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml deleted file mode 100644 index 86fc82623da1..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml +++ /dev/null @@ -1,10 +0,0 @@ -[packaging] -package_name = "azure-mgmt-chaos" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Chaos Management" -package_doc_id = "" -is_stable = true -is_arm = true -need_msrestazure = false -need_azuremgmtcore = true -title = "ChaosManagementClient" diff --git a/sdk/chaos/azure-mgmt-chaos/setup.py b/sdk/chaos/azure-mgmt-chaos/setup.py deleted file mode 100644 index 189ec22d9181..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-chaos" -PACKAGE_PPRINT_NAME = "Chaos Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.5.0", - ], - python_requires=">=3.9", -) diff --git a/sdk/chaos/azure-mgmt-chaos/tsp-location.yaml b/sdk/chaos/azure-mgmt-chaos/tsp-location.yaml new file mode 100644 index 000000000000..fd4d4340510d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/chaos/resource-manager/Microsoft.Chaos/Chaos +commit: 84d40416fbb3d2416cb7abe7ec82e63c76832963 +repo: Azure/azure-rest-api-specs +additionalDirectories: